Issue
I am new to Linux command.
I have below content in the tst.out file. I want to remove all the row string starting till third '|'
:
MIN AU 09/15/22 C39.5 Equit|0|75|MIN 9 C39.50|AU|BBG018NNGHR1|
TIN AU 09/15/22 C39.9 ITY|0|75|RIN 9 D39.50|AU|BBG018NNGHR45|
CIN AU 09/15/22 C39.8 Ref|0|75|PIN 9 F39.50|AU|BBG018NNGHR66|
After removing of row string starting till third '|'
, the file content should look like below:
MIN 9 C39.50|AU|BBG018NNGHR1|
RIN 9 D39.50|AU|BBG018NNGHR5|
PIN 9 F39.50|AU|BBG018NNGHR6|
Can you please tell how to achive this using sed
command in Linux ?
Thanks!
Solution
Using sed
$ sed -E 's/([^|]*\|){3}//' input_file
MIN 9 C39.50|AU|BBG018NNGHR1|
RIN 9 D39.50|AU|BBG018NNGHR45|
PIN 9 F39.50|AU|BBG018NNGHR66|
Answered By - HatLess Answer Checked By - Mildred Charles (WPSolving Admin)