LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 01-29-2008, 05:00 PM   #1
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Rep: Reputation: 15
Bash script that writes to files


Hi,

I'm trying to make a bash script that will write to a file. Normally you'd say "just use echo "..." >file.txt" but I'm not looking for that. I want to be able to write to the end of the file. Is there a way to count the lines from the file and then write at the bottom of it ? I'm sure there is, but I can't find it.

Is there anybody who could tell me some sites with examples of this kind of file writing or something like that ?


Thanks in advance !
Kind regards,
Steve
 
Old 01-29-2008, 05:05 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Writing to the end of a file (appending) is done with >> instead of >. For example:
Code:
echo "Something" >> file.txt
Was that what you wanted to do?
 
Old 01-29-2008, 05:07 PM   #3
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
beat me to it
 
Old 01-30-2008, 05:29 PM   #4
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by gilead View Post
Writing to the end of a file (appending) is done with >> instead of >. For example:
Code:
echo "Something" >> file.txt
Was that what you wanted to do?
That was exactly what I wanted
Thanks !
 
  


Reply



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
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM
run files using BASH script kkpal Programming 2 11-02-2007 08:21 AM
bash script on manipulating files fiomba Linux - Software 8 10-30-2004 08:31 PM
Identifying files in bash script Cruger Programming 7 03-15-2004 10:49 AM
bash script to rm all files in a dir keirobyn Programming 8 07-19-2002 07:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:56 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
Open Source Consulting | Domain Registration