LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to send shell variable data to a text file (https://www.linuxquestions.org/questions/programming-9/how-to-send-shell-variable-data-to-a-text-file-457513/)

ginda 06-23-2006 05:05 AM

how to send shell variable data to a text file
 
Writting a very very simple shell script, the script contains some variables which i want displayed with a sentence i.e.

hello $1 whats up, what you doing $2
do you like $3

I want to send this data to a text file, i tried

cat << _EOF_


blah blah blah


_EOF_

>> /home/blah/blah.log


any ideas how to achieve this.

Thnaks in advance.

prozac 06-23-2006 05:14 AM

"hello $1 whats up, what you doing $2" > somefile.txt
"do you like $3" >> somefile.txt

ginda 06-23-2006 05:22 AM

would the text be written to file exactley hows its presented in the text, i.e. the overal format, positioning of each sentence.

Thanks

prozac 06-23-2006 05:26 AM

yes, most probably. just try to format the content as you would like to appear in the text file and re-direct in to the file. its more like try and correct thing.

spirit receiver 06-23-2006 05:28 AM

Try it the other way round:
Code:

cat > file << EOF

jschiwal 06-23-2006 05:31 AM

Put the redirection on the same line as the cat command:
cat << _EOF_ >> ~/blah.log

ginda 06-23-2006 05:45 AM

Thanks guys, really helpful stuff, this is why i love being part of this community :)

prozac 06-23-2006 05:49 AM

yeah, we love it too ;)


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