You are not logged in.

#1 2008-01-02 20:53:56

lenni
Member
From: London, UK
Registered: 2007-09-21
Posts: 95

Adding text to the end of a file with ed or vi

I've been googling for a while but have not found an answer.

The ed tutorial always discuss everything in such detail but I only want to know how to add some text to the end of a file as part of a shell script.

Offline

#2 2008-01-02 20:55:59

barry
Member
Registered: 2007-11-27
Posts: 39

Re: Adding text to the end of a file with ed or vi

echo "random text" >> filename

Offline

#3 2008-01-05 20:53:06

magnum_opus
Member
Registered: 2005-01-26
Posts: 132

Re: Adding text to the end of a file with ed or vi

ed foo.txt
a
words
.

a for append, then end a single . on a line ends append mode
w and q to save and quit of course

not quite sure how to do it with vi, though in ex mode the ed commands work fine

Offline

#4 2008-01-05 21:46:31

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Adding text to the end of a file with ed or vi

The tee command allows more control than redirecting:

echo "message" | tee -a

Offline

Board footer

Powered by FluxBB