a dummy question on data processing

Hi, everyone,
I have a matrix, let's say:

1 2 3 4 5 6 ...
4 5 6 7 8 9 ...
7 8 9 1 2 3 ...
3 4 5 6 7 8 ...
.........
(nxm matrix)

Is there a simple command that can take certain specific rows out of the matrix?
e.g., I want to take row 2 (4 5 6 7 8 9 ...) and row 4 (3 4 5 6 7 8 ...) out and put them into another file. I failed to do that with "grep". Do y'all have any idea ? Thanks.
Also, how to remove certain specific rows from the original file? (I know cut works if I want to remove columns, but how about rows??) Thanks a lot. :b:

With awk:

awk 'NR==2 || NR==4' file > newfile

for the 2nd question:

awk 'NR!=2 && NR!=4' file > newfile

Regards

Thanks a lot!! :):slight_smile: