Please help to delete lines in a file

Dear All,
I m trying to delete two lines at a time in file called 123.txt. Im using sed and based on line numbers i m deleting it and writing it to another file. Follwing i have done.

cat 123.txt | sed '1,5 d' > new

I want to delete line no 1 and 5 at a time, for that i m using sed. But instead it is deleting all the five lines. please help me.

cat -n 123.txt

 1  This is the 1 line
 2  This is the 2 line
 3  This is the 3 line
 4
 5  My name

Thank & Regards
Naree

Something like:

 awk 'NR==1||NR==5{next}1' file > newfile

Regards

sed -n '2,4p' file > new

Thanks
Penchal

Dear All,
Thanks for u r replies. But requirement of line number changes as my script will execute and take some 3 or 4 line numbers at a time. So please help me according to that.

Thanks & Regards
Naree

You can use something like this:

awk '!(FNR~/^(1|3|5)$/)' filename

If it's not only a one-time operation,
use a script:

$ cat file
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
$ ./s "1 5 9" file
line2
line3
line4
line6
line7
line8
line10
$ ./s "10 3 8" file
line1
line2
line4
line5
line6
line7
line9
$ cat s
#! /usr/bin/nawk -f

BEGIN {
if (ARGC < 3) {
  printf "usage: %s line_number1 [line_number2 line_number3 ...] filename1 [filename2 ...]\n", ARGV[0]
  exit 255
  }
gsub(/  */, "|", ARGV[1])
lines_to_remove = "^(" ARGV[1] ")$"
ARGV[1]=""
}

!(FNR ~ lines_to_remove)

Use nawk or /usr/xpg4/bin/awk on Solaris.

Simply use the following,

sed -e '1 d' -e '5 d' abc.txt > new_file

Dear All,

       Thanks a Lot to all ur replies. Esp. to Mr.radoulov. It really worked.

Thanks & Regards
Naree