Для кратных |
в строках:
astr | bstr | cstr | dstr
Жадный матч
sed 's/.*|//' < file # will result: ` dstr`
sed 's/.*|/|/' < file # will result: `| dstr`
Нежадное совпадение
sed 's/^[^|]*|//' < file # will result: ` bstr | cstr | dstr`
sed 's/^[^|]*|/|/' < file # will result: `| bstr | cstr | dstr`
короче - с помощью команды cut
cut -d'|' -f-1 < file # will result: `astr `
cut -d'|' -f-2 < file # will result: `astr | bstr `
cut -d'|' -f2- < file # will result: ` bstr | cstr | dstr`
cut -d'|' -f3- < file # will result: ` cstr | dstr`
cut -d'|' -f2 < file # will result: ` bstr `
cut -d'|' -f2-3 < file # will result: ` bstr | cstr`
cut -d'|' -f2,4 < file # will result: ` bstr | dstr`