Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Stripping 2 lines from the top of a text file.

 
Highlighted
Valued Contributor

Stripping 2 lines from the top of a text file.

I am trying to strip the top two lines from a data file from with in script and put the output to a second file.

I need a refresher on a quick sed or awk command to strip Line 1 and Line 2 from a variable length file.

Any thoughts appreciated.

4 REPLIES 4
Highlighted
Valued Contributor

Re: Stripping 2 lines from the top of a text file.

Disregard, found my notes.

sed '1,2d' file1.ext > goodfile.ext

Highlighted
Acclaimed Contributor

Re: Stripping 2 lines from the top of a text file.

Hi:

# sed -ne '1,2p' file > file_of_2

Regards!

...JRF...

Highlighted
Valued Contributor

Re: Stripping 2 lines from the top of a text file.

Jim, Thanks.. I found it.

Have another issue, will post a new question..
Highlighted
Acclaimed Contributor

Re: Stripping 2 lines from the top of a text file.

To skip the first 2 lines of a file you can simply use tail:
$ tail +3 file1.ext > goodfile.ext