unix - Removing column in pipe delimited file when the text matches with search string -
I need to find a particular text in a separate file and remove the column that matches the text.
ex: My file
1 | 2 | Test123 | 3 | 4 | 5 .... | 6 6 7 | 5 | Test123 | 10 | 11 ..... | N 6 | 7 | 1 | 9 | Test123 | 11 ..... | N
Need to search the column that contains "test" and that removes the column
the new file should appear
< Pre> 1 | 2 | 3 | 4 | 5 .... | 6 6 7 | 5 | 10 | 11 ..... | N 6 7 | 1 | 9 | 11 ..... | N
I've tried
awk 'BEGIN {FS = OFS = "|"} {$ 2 = $ 3 = ""; Gsub (/ [|] + /, "|")} 1 'test.txt & gt; & Gt; Test5.txt
Order where the column number is clearly difficult, but a script is needed which will search for the text and then delete the column.
2 | Test123 | 3 | 4 | 5 .... | N 6 7 | 5 | Examination 123 | 10 | 11 ..... | N 6 7 | 1 | 9 | Examination 123 | 11 ..... | N
script:
sed 's / test123 | // 'file.txt & gt; & Gt; File1.txt
Comments
Post a Comment