LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-15-2004, 04:40 AM   #1
Skute
Member
 
Registered: Jul 2003
Distribution: SUSE 9.0 Pro
Posts: 45

Rep: Reputation: 15
Writing to a file - Bash script


Hi, how can i write a load of text into a file with a bash script?

I have about 5 different variables and i want to write them + some pre-written text into a file.

thanks
 
Old 03-15-2004, 04:45 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
To overwrite a file use something like echo $bleh > newfile, or to append to a file use the >> operator.

Hkan
 
Old 03-15-2004, 05:41 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,298

Rep: Reputation: 175Reputation: 175
the best way maybe, use "here" document:
which writes until reaching a guard string, conventionally
EOF or EOD

e.g:

cat > ouput.file.name <<EOF

put all you need here
variables will work normaly

var1 = $var1
var2 = $var2

blah
blah

EOF

the EOF ends the output, put it at the beginning of the line.


billy
 
  


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
BASH script reading and writing variables to a separate file morrolan Programming 10 09-20-2005 08:45 AM
writing a bash script poiuytrewq Linux - Newbie 2 10-07-2004 11:26 PM
Writing bash script with recursion.. ray5_83 Programming 4 08-04-2004 06:44 PM
Help writing a pinging bash script dehuszar Linux - Software 3 06-18-2004 03:03 PM
writing bash script ankitgdit Programming 4 08-19-2003 07:47 AM


All times are GMT -5. The time now is 03:33 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 Google+: linuxquestions
Open Source Consulting | Domain Registration