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 03-14-2005, 01:19 PM   #1
Boffy
Member
 
Registered: Jul 2003
Location: Durham, UK
Distribution: Ubuntu 8.04
Posts: 419

Rep: Reputation: 30
Create a text file using Bash


Is there anyway to echo some data to a text file using a bash script?

Boffy
 
Old 03-14-2005, 01:26 PM   #2
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Code:
echo data > data.txt
will create a file called data.txt containing data.
If the file exists it will be overwritten.
Code:
echo data >> data.txt
will add data to the end of the file data.txt.
It will create it if it doesn't exist.

Hope this helps.
 
Old 03-14-2005, 01:27 PM   #3
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Rep: Reputation: 16
You might try echo

#!/bin/sh
echo "Inputing data into /home/user/test.txt"
echo "Hello Bob" > /home/user/test.txt
 
Old 03-14-2005, 01:33 PM   #4
Boffy
Member
 
Registered: Jul 2003
Location: Durham, UK
Distribution: Ubuntu 8.04
Posts: 419

Original Poster
Rep: Reputation: 30
Thanks thats just the sort of thing I was looking for. You have no idea how hard trying to find that on google was.
 
Old 03-14-2005, 02:22 PM   #5
Savahn
Member
 
Registered: Mar 2003
Posts: 36

Rep: Reputation: 16
Also if you just want to create a text file but leave it emtpy use touch

#!/bin/sh

touch /home/user/text.txt
 
1 members found this post helpful.
Old 03-14-2005, 09:06 PM   #6
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
Quote:
Originally posted by Boffy
Thanks thats just the sort of thing I was looking for. You have no idea how hard trying to find that on google was.
Google for this tar ball.
abs-guide-2.6.
 
  


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
create text file from terminal acidjuice Linux - Software 8 09-03-2010 03:46 AM
bash: split text file iluvatar Programming 4 08-22-2005 08:58 AM
Need help reading text file in bash script scilec Programming 3 11-25-2004 06:44 PM
send text to file bash bendeco13 Linux - General 6 11-01-2004 06:26 PM
Create text file with a script zael Programming 3 06-02-2004 03:27 AM

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

All times are GMT -5. The time now is 08:25 AM.

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