Deletion of lines in a text file

Hi Everyone,
Please help me with this. I have gone through many posts here but couldn't find what I wanted.

I have a file with 79000+ lines and I want to delete lines in a pattern.

I want to delete every 141st line in the file, starting from line 2000 till 50000.

Please help guys.

Regards,
Abhi

Try this :

sed -n '2000,50000p'  file | awk '{ if ((NR%141) != 0) print $0; }'

Half of my problem is solved now....only thing left is that, what should i do to get the lines before and after the starting and ending points.

Anyways thanks very much for this help.

Regards,
Abhi

Try like this:

awk '{ if ((NR>=2000) && (NR<=50000)) { if ((NR%141) != 0) print $0; } else print;}' filename

Thanks Dennis.

That helped !!!

U r great,,....

One more thing....

I was trying to remove the 141st line after the start point (line 171) ....
i.e. (171 + 141)st line
so I tried the script
awk '{ if ((NR>=2000) && (NR<=50000)) { if ((NR+141) != 0) print $0; } else print;}' filename

But this is not working and instead printing everything intact.

Please can someone help.....

Dennis... be a savior again

Regards,
Abhi

Something like this?

awk 'NR>=2000 && NR<=50000 && NR%141==30{next}1' file

Regards

Its giving syntax errors....i think something is missing....

Anyways I am trying to understand it and modify it...

Try nawk, gawk or /usr/xpg4/bin/awk on Solaris if you get errors.

regards