LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-08-2011, 12:12 PM   #1
etika
Member
 
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

cat>>file.txt
adasds
^D
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
assasas
^D`
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
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 450Reputation: 450Reputation: 450Reputation: 450Reputation: 450
Hi,

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

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

Code:
cat>>file.txt
Run the script and write your text:

Code:
asdasdasd
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
etika
Member
 
Registered: Dec 2010
Posts: 38

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


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:33 PM.

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