Computing.Net > Forums > Unix > Adding Blank lines at start of 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.

Adding Blank lines at start of file

Reply to Message Icon

Name: sushilp
Date: June 20, 2003 at 04:27:11 Pacific
OS: Sun Solaris
CPU/Ram: P4/512
Comment:

Hi
I want to add 3 blank lines at the start of a file
can u help me with the command



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: June 20, 2003 at 04:49:04 Pacific
Reply:

echo "" > tmpfile
echo "" >> tmpfile
echo "" >> tmpfile
cat oldfile >> tmpfile
mv tmpfile oldfile


0

Response Number 2
Name: nails
Date: June 21, 2003 at 11:00:27 Pacific
Reply:

David's is an easy, straightforward solution to this problem.

However, if you'd like to edit the file in place, you can do this:

vi yourfile > /dev/null 2>&1 MSG
O

^[
:wq
MSG
# Uses unix document, need two less than signs before the first MSG. This forum wipes out these characters.

1) "O" opens the first line in vi.
2) Place the required CRs
3) Press the ESC key. Emulate the ESC key in vi by pressing control-v, and then hitting ESC.
4) vi quits with :wq

Regards,

Nails


0

Response Number 3
Name: Dlonra
Date: June 23, 2003 at 08:32:29 Pacific
Reply:

i prefer ex instead of vi for scripting
ex yourfile MSG
0i


.
wq
MSG


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Learning About UNIX Help needed ! Mail throug...



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: Adding Blank lines at start of file

duplicate line in middle of file www.computing.net/answers/unix/duplicate-line-in-middle-of-file/5226.html

Remove blank lines between two line www.computing.net/answers/unix/remove-blank-lines-between-two-line/5208.html

script help www.computing.net/answers/unix/script-help/6044.html