My file looks like this
abc ||| xyz ||| foo bar
hello world ||| spam ham jam ||| blah blah
I want to extract a specific column, e.g. I could have done:
sed 's/\s|||\s/\\t/g' file | cut -f1
But is there another way of doing that?
cutdelimitersed
My file looks like this
abc ||| xyz ||| foo bar
hello world ||| spam ham jam ||| blah blah
I want to extract a specific column, e.g. I could have done:
sed 's/\s|||\s/\\t/g' file | cut -f1
But is there another way of doing that?
Best Answer
Since
|
is a valid regex expression, it needs to be escaped with\\|
or put in square brackets:[|]
.You can do this:
Some other variations that work as well:
Example: 4
\
for every\
in the expression, so 12\
in total.or
or this but it's not much simpler