Hi all,
I want transfer the echo data into file.txt.how?
echo " $dir $group " >> ${file.txt}
---------- Post updated at 04:11 PM ---------- Previous update was at 03:10 PM ----------
anybody can help ?
i mean in script output like
echo " hello"
i want transfer that output to file.txt.
It is not very clear what you are asking for here, so I will take a guess..
To echo simple variables into files use something like:
echo "$dir $group" >> file.txt
However if you want to echo variables into a filename that is held in a variable:
fname="file.txt"
echo "$dir $group" >> $fname
Please note that ">>" appends to the file. If you want to create the file new each time just use one redirect ">"
I would recommend searching for "simple shell script tutorial" on your favourite search engine.
I hope this helps.
hi citaylor,
then i need to set as variable in my script?
The first example is an example of a hard-coded file name, ie "file.txt".
The second example is an example of a file name kept in a variable that is usually set in the script.
Another example is:
#!/bin/sh
echo "$dir $group" >> $1
"$1" is special, it means use the first argument passed to the shell script, so if you then ran the shell script, for example "./script foo.txt" then the output would be stored in foo.txt
Hi
if i want get the output of $fname ?how i going to type the code?
because i type echo $fname nothing come out.