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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a string into a file? 2

Status
Not open for further replies.

chrislx

Programmer
Oct 17, 2003
32
US
I am new on UNIX script programming. Here is my question, please help.

1) check if a file exists, if not, create a new file
if [ ! -f "$MINENV_RUN/work/$I" ] - it works
then touch $MINENV_RUN/work/$I

2) add a string into the file
string entered: "aaa, bbb, ccc, ddd"

How can I add the string to a file?

Thanks,

chrislx

 
echo "aaa.bbb.cccc.ddd" >> to $file

It is important to have the >>. That means append the file. If you only have 1 > then you will overwrite the file each time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top