cat test.nmea|awk 'NR%3!=0'
This deletes the 3rd line, or I can delete the fourth but I can't figure out how to delete the 3rd and 4th together. I'm looking for a quick way to make a GPS log half its size.
Also how do I pipe the output to another file?
Hope someone can help!
that is a strange way to truncate a log file but if you must this should work... no need for cat.
awk 'NR%3!=0 && NR%4!=0' test.nmea >new.file
frank_rizzo's solution deletes lines 3,4,6,8,9,12,15,16 (any line divisible by 3 or 4)
If you want to delete 3,4,7,8,11,12,15,16 (line 3 & 4 out of every group of 4) then you want:
awk 'NR%4==1 || NR%4==2' test.nmea > new.file
perl -i -pe 's/.*\s*$// if ($.%3==0 || $.%4==0);' infile
binlib
December 8, 2010, 9:32am
5
With Gnu sed:
sed '3~4d;4~4d'
or
sed '3~4,4~4d'
I think Chuble_XL is right in interpreting OP's intention.
awk 'p=!p;{getline}p' infile
sed -n 'p;n;p;n;n' infile