I have a file with the following structure:
H|123450|1203|dsf5|trtr
H|123949|4940|erjvh|hdhgd
H|01-JAN-06|2398|jk55k|gdfbn
H|120983|3894|sdfklj|fsdkf
H|29-DEC-06|2398|lsdfj7|sflkj
H|934806|2304|reoi5|sljks
The file is in pipe delimited format as shown above. It is huge and cannot use vi, I have to delete the records which have the date format in the second field(01-JAN-06). How can i do this without using vi? any sed commands for this??
H|123450|1203|dsf5|trtr
H|123949|4940|erjvh|hdhgd
H|01-JAN-06|2398|jk55k|gdfbn
H|120983|3894|sdfklj|fsdkf
H|29-DEC-06|2398|lsdfj7|sflkj
H|934806|2304|reoi5|sljks
The file is in pipe delimited format as shown above. It is huge and cannot use vi, I have to delete the records which have the date format in the second field(01-JAN-06). How can i do this without using vi? any sed commands for this??
I would use awk, there's a tutorial here:
http://www.vectorsite.net/tsawk.html
example code would be:
awk -F'|' '$2 ~ /^[0-9]+$/' test.txt > test2.txt
http://www.vectorsite.net/tsawk.html
example code would be:
awk -F'|' '$2 ~ /^[0-9]+$/' test.txt > test2.txt
If the second field is the only one with dates, a simple
grep -v '|01-JAN-06|' yourfile > newfile
should do it. You might need \| in place of | in that command, I can never remember until I try it.
grep -v '|01-JAN-06|' yourfile > newfile
should do it. You might need \| in place of | in that command, I can never remember until I try it.
I would use awk, there's a tutorial here:
http://www.vectorsite.net/tsawk.html
example code would be:
awk -F'|' '$2 ~ /^[0-9]+$/' test.txt > test2.txt
http://www.vectorsite.net/tsawk.html
example code would be:
awk -F'|' '$2 ~ /^[0-9]+$/' test.txt > test2.txt
can you copy it to a local machine, make the changes in a text editor and upload the new file?