LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 03: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, 03:45 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

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

Håkan
 
Old 03-15-2004, 04:41 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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 07:45 AM
writing a bash script poiuytrewq Linux - Newbie 2 10-07-2004 10:26 PM
Writing bash script with recursion.. ray5_83 Programming 4 08-04-2004 05:44 PM
Help writing a pinging bash script dehuszar Linux - Software 3 06-18-2004 02:03 PM
writing bash script ankitgdit Programming 4 08-19-2003 06:47 AM

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

All times are GMT -5. The time now is 01:13 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