LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 11-18-2004, 06:09 PM   #1
alts
LQ Newbie
 
Registered: Nov 2004
Posts: 13

Rep: Reputation: 0
Appending Text Files From Bash Script


Hello all. Newb here again.

I have a script that is simply piping standard input (from keyboard) into a text file:

cat >> myFile.txt

What I woudl like to do is actually append this file everytime the script is run. I'm pretty sure I use the "sed" command but I am a little confused as to whether or not I should use the "tail" command or not instead. Basically, I want the new text entered inot my shell to be placed after the last line of text in the file. I can only find examples of finding text that exists and editing it, not going to the blank spot and entering it there.

Help?

Cheer,
alts
 
Old 11-18-2004, 06:22 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OEL
Posts: 9,165

Rep: Reputation: 243Reputation: 243Reputation: 243
Code:
cat >> myFile.txt
is already appending stdin to the file.
 
Old 11-18-2004, 06:29 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 53
cat > MyFile.txt would overwrite the file, but cat >> MyFile.txt (the way you have it) appends to the file.
 
Old 11-18-2004, 06:36 PM   #4
alts
LQ Newbie
 
Registered: Nov 2004
Posts: 13

Original Poster
Rep: Reputation: 0
My mistake, sorry for wasting the bandwith!

Thank you. I was reading the wrong file.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script text replacement... matthurne Programming 4 06-07-2011 06:46 PM
Bash script text line into an array toolshed Programming 1 06-13-2005 05:49 PM
bash script help to parse out text slack guy Linux - Newbie 3 12-30-2004 08:42 AM
Need help reading text file in bash script scilec Programming 3 11-25-2004 06:44 PM
Bash script - reading from text file twantrd Programming 4 11-24-2004 12:38 AM


All times are GMT -5. The time now is 02:54 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration