Using sed command I want to delete every other three lines from a file which has e.g. 99 lines in total. I mean to keep the first three lines and delete the second three lines and so on.
My starting script is as below:
for i in `seq 1 6 99`; do
sed '$i,${i+2}!d' test.txt > o$i.txt
done
cat o*.txt > O.txt
rm o*.txt
Individual i works fine, likes
sed '1,3!d' test.txt > o1.txt
sed '7,9!d' test.txt > o7.txt
...
But it doesn't works inside sed. Would you please let me know where I am doing wrong? Thanks