Hello I have a file with lines such as
27/12/20 | 05:50:48pm | abcdefgh |ID:1:418856791 | jack | 188.8.131.52:1111 | IN | GN-4536 | LOL | 0 27/12/20 | 05:51:44pm | abcdefgh |ID:1:503729784 | jill | 184.108.40.206:2222 | IN | GN-497187 | LOL2 | 0
There is a big file with such lines. How can I extract only GN-4536 & GN-497187 from this file? Like it can be anything GN-numbers. How can I get the output in format like
I tried using sed & grep commands but It could extract the number. I used to only get the result as GN.
Someone plzz help me
This is pretty easy with
$ cut -f8 -d'|' filename GN-4536 GN-497187
This cuts the
| (which must be escaped from the shell).
But it leaves in the whitespace. You can strip that with
$ cut -f8 -d'|' filename | tr -d ' ' GN-4536 GN-497187
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.