I want to remove all lines where the second column is 05408736032.
0009300|05408736032|89|01|001|0|0|0|1|NNNNNNYNNNNNNNNN|asdf| 0009367|05408736032|89|01|001|0|0|0|1|NNNNNNYNNNNNNNNN|adff|
|
I want to remove all lines where the second column is 05408736032. 0009300|05408736032|89|01|001|0|0|0|1|NNNNNNYNNNNNNNNN|asdf| 0009367|05408736032|89|01|001|0|0|0|1|NNNNNNYNNNNNNNNN|adff| | ||||
feedback
|
|
This might do what you want:
However this sorts the input according to your field, which you may not want. If you really only want to remove duplicates, your best option is Perl:
| |||
|
feedback
|
| |||||
feedback
|
|
Pure Bash:
| |||
|
feedback
|
|
You can do something like:
but, like most shell scripts, it's pretty inefficient. You'd be better off doing it in perl, something like:
| |||
|
feedback
|
|
Is it that you want to remove all lines where the second | separated field contains '05408736032'? Will all the lines be formatted the same? If so, this should output the file minus those lines (it's perl that takes the original file as the first argument and the file it's going to as the second).
(I haven't tested this, so you probably want to backup the original file before you try it) On reading again, you may be looking to grab only lines with a unique second column. This should do that.
| ||||
|
feedback
|