Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-08-2011, 12:12 PM   #1
Registered: Dec 2010
Posts: 38

Rep: Reputation: 0
shell script for appending data to a file

hello people

this is how we append a file at command line its like

but how to write the code for appending a file in a shell script i tried but its not running
cho "the contents of the file before appending"
cat ab.txt

echo `cat >> ab.txt
echo "the contents of the file after appending"
cat ab.txt

please help me to rectify my script
Old 02-08-2011, 12:40 PM   #2
Senior Member
Registered: Jan 2010
Posts: 1,665

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492

do you mean something like this
echo "append this" >> file.txt
or to append a file to another
cat append_me.txt >> file.txt
Old 02-08-2011, 01:27 PM   #3
Senior Member
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Put your command into the script:

Run the script and write your text:

If each text line you write should appear in the separate line press Enter.

Finally press Ctrl+D.
Old 02-08-2011, 08:56 PM   #4
Registered: Dec 2010
Posts: 38

Original Poster
Rep: Reputation: 0
thanks i got it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use Shell script to edit a data at a particular location in a txt file? leena_d Programming 30 02-08-2010 01:43 AM
Shell script for read user data with emptyLines in a text file and filter them srimal Linux - Newbie 7 11-01-2009 05:37 AM
Shell script to read lines in a text file and filter user data srimal Linux - Newbie 5 10-21-2009 08:41 AM
need to write a shell script for appending text into each line of a file nandakv4 Programming 9 08-15-2009 04:32 AM
How to read data from file to use in shell script? ozymandias Linux - Newbie 7 10-27-2006 02:19 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration