Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert blank line at line no.1

Status
Not open for further replies.

dbase77

Technical User
Apr 23, 2002
591
IE
Hi,

Anybody knows how to insert blank line at line number one in a file?

Thanks.
 
Hi,

Got error "sed: illegal option -- i".
 
Dont have newer version. I guess I have to find another way of doing it.

Thanks.
 
Hi

You could search this forum, the question is not new.

Practically all solutions implies the creation of a temporary file. ( [tt]sed[/tt] also does that way. ) So :
Code:
(
  echo "the new line"
  cat /the/file
) > /temporary/file
mv /temprary/file /the/file
Another way is to pipe the necessary commands to [tt]vi[/tt] and make it execute them in kind of batch mode. Again, search this forum.

Feherke.
 
Got solution from sed using below:

sed '1i\
' test > test.out

Thank you for your help. At least give me some idea.

regards,
dbase77
 
Practically all solutions implies the creation of a temporary file
not all:
echo "O\033:wq" | vi /path/to/file >/dev/null 2>&1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi

Ok, then...

Practically all solutions implies the creation of a temporary copy, usually in a file.

Anyway, I am not so sure, that [tt]vi[/tt] will not create a temporary file.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top