LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I need HELP Writing text to a FILE (http://www.linuxquestions.org/questions/linux-newbie-8/i-need-help-writing-text-to-a-file-679832/)

ravi2ray 10-29-2008 03:12 PM

I need HELP Writing text to a FILE
 
I am looking for help on writing to a text file:

Lets say i have a file name text.text and i want to echo out "enter name"
then echo "enter age". The collected information i would like to append it to a file that is created when the function is called:

function addText() {

name=$1
age=$2

folder="$HOME/dir/"

fileName=${folder}dir${age}.txt
tempFile=${folder}films${name}Temp.txt

echo "$name" >> $fileName

}

input:
Enter Name: Raymond
Enter Age: 20

next input:

enter name: ray
enter age: 22


the Output inside the file should look like:

"Raymond", "20"
"ray", "22"

... etc

TB0ne 10-29-2008 03:17 PM

Quote:

Originally Posted by ravi2ray (Post 3325342)
I am looking for help on writing to a text file:

Lets say i have a file name text.text and i want to echo out "enter name"
then echo "enter age". The collected information i would like to append it to a file that is created when the function is called:

... etc

"Captain, sensors indicate a class 4 homework alert ahead...."

chrism01 10-29-2008 07:06 PM

http://catb.org/~esr/faqs/smart-questions.html
http://www.linuxquestions.org/linux/rules.html

ravi2ray 10-29-2008 10:09 PM

[QUOTE=TB0ne;3325347]"
Captain, i am working in a project which is almost done. I need to learn how to do things differently in order to become better.

This peace of code works but i don't like it:

echo "$age" >> some.txt

ravi2ray 10-29-2008 10:10 PM

Thank you. These links are helpful.


All times are GMT -5. The time now is 02:22 AM.