wanna to save the input to a file
am currently working with shell scripting in Linux and this is what.. I wanna to achieve..
I have a file named "a" having some parameters in it. for ex: color= red and boys = 10. Now, I wanna to run a script, so that It will ask the values of color and boys from me to input,. I will then enter color-green and boys=12. Then it will update those values into the file "a". So that, when I will open the file :"a".. I will find the update values of color and boys as green and 12 respectively. As per my understanding, we need to locate the address of variable color and boys that were stored the values as red and 10 respectively earlier. Then we need to replace those values as green and 12 to that memory location. Kindly suggest me, if this will work or you have different opinion. Thanks for your time ... and sorry to distrub you... Hope you don't mind.. Thanks, |
You haven't said what shell, but here's an idea in bash:
Code:
#!/bin/sh Code:
root@beren [~/scripts/shell]# cat lq.txt Code:
root@beren [~/scripts/shell]# cat lq.txt Hope that helps. |
Well, it might also be even simpler than that.
"Every Linux/Unix program" has the notion that it reads its input from STDIN, writes its output to STDOUT, and sends its error-messages to STDERR. All three of these names are abstract names: you can define, on the fly, what these input-files belong to. By default, STDIN will be "your terminal" and both STDOUT and STDERR will also be "your terminal." Now, let's say that this time when I run my program, I want to read the input from one file, write the output to another, and simply dispose-of any errors. Code:
myprogram <inputfile >outputfile 2>/dev/null What if we'd like to pipe the output of one program straight into the mouth of another one? Easy: Code:
foo | bar Quote:
|
All times are GMT -5. The time now is 12:30 AM. |