Computing.Net > Forums > Unix > Delete first line of a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete first line of a file

Reply to Message Icon

Name: covina
Date: October 6, 2006 at 12:30:03 Pacific
OS: AIX 5.2
CPU/Ram: 512
Product: IBM
Comment:

How do i delete first line of a file. The file starts with page break ^L. The first line contains the page break ^L. The file may have multiple pagebreaks and I don't want to delete from the file. I want answers in unix shell script, using sed or nawk commands or anyting simpler than that.

Any help will be appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 6, 2006 at 12:42:06 Pacific
Reply:

This simple sed command deletes the first line, no matter what the line contains:

sed '1d' data.file > mynewdata.file


0

Response Number 2
Name: James Boothe
Date: October 6, 2006 at 13:39:35 Pacific
Reply:

Typically, the formfeeds occur at the beginning of the first line of each page. So if you delete the entire line, it will cause the first page to be missing the first line, and all remaining lines on that page will move upward one line.

To delete only the Ctrl-L, and leave the first line there (even if otherwise blank), you can do:

sed 1s/^L// data.file > mynewdata.file

(and key that as an actual Ctrl-L)

or you can use the \f designator:

sed 1s/"\f"// data.file > mynewdata.file


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Delete first line of a file

Get the first line from a file www.computing.net/answers/unix/get-the-first-line-from-a-file/7981.html

Extracting lines from a file www.computing.net/answers/unix/extracting-lines-from-a-file/5403.html

Printing last few pages (or lines) of a www.computing.net/answers/unix/printing-last-few-pages-or-lines-of-a-/2268.html