On Sat, 5 Nov 2016 00:13, Greg Freemyer wrote:
I have a long file full of tab-separated records.
A couple samples lines:
99616256-ZIP-335231 378599456976549 4797677379\x097997/378507976549\x0977-\x09949776-791/ 99616256-ZIP-915437 4597093459474773 4770\x097428-84473-4597009474773-877-4-045270947 9
I'm only interested in the middle field:
378599456976549 4597093459474773
I'm thought I could use sed to strip off the first word via:
sed -i "s|.*\t||" filename
But that is deleting both of the first 2 fields.
What's the right magic sed command?
Ah! You forgot that the "*" is greedy, and takes everything from the start to the last possible match. I'd start by thinking about either using a two parter, or grouping. Two parter (remove from start up to and including first tab, remove from second tab to end): sed -e 's,^[^\t]*\t,,' -e 's,\t[^\t]*$,,' or, use grouping: sed -e 's,^[^\t]*\t\([^\t]*\)\t[^\t]*$,\1,' Does this give you the missing hint? - Yamaban. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org