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!

Append to the end of a line 1

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
How can I append to the end of a line with a shell script?

I know I can append usin ">>", but I do not want it to start on a new line.

Thanks for any guidance.
JE
 
Hi,

You could use sed and replace the end of line character ($)with the new text

sed 's/$/New Text/g' filename > newfile

Matt.
 
Not sure if I can do it this way, because it is a log that is continuous.

This method would put "New Text" at the end of each line. I want to append to the end of the most recent line written to the file.

I'm having a batch procedure run... it writes..

STEP1 Disable Site

Then after it disables a site, i want it to append like this.. by adding "Done"

STEP1 Disable Site Done


thanks!
JE




 
Only append to the last line...
[tt]
sed '$s/$/Done/g' filename > newfile
[/tt]
But perhaps you could use...
[tt]
echo "Step 1 \c" >> filename
:
echo "Done" >> filename
[/tt]
 
Exactly what I was looking for Ygor.

Thanks!
JE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top