LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script to edit a file (http://www.linuxquestions.org/questions/linux-newbie-8/shell-script-to-edit-a-file-646362/)

kaash_m31 06-02-2008 05:19 AM

Shell script to edit a file
 
Hi Experts,

I am new to shell scripting.I have a requirement, in which I have to fill a value of a parameter using a script.

for example:
I have a file ("testfile.txt") whose contents are:
================================
line1.color: red
line2.size:10
line3.path:
line4.display:default
================================

In the above content of file, I have to fill the third parameter with some value say "/usr/dir". Please help me in writing a script to fill that value.
Thanks in advance.

unSpawn 06-02-2008 05:36 AM

If you have no clue then best start here I think:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.tldp.org/LDP/abs/html/

pinniped 06-02-2008 05:43 AM

Sounds like a job for 'sed' (I can't see how the shell would do it all - then again I'm definitely no shell guru).

This sounds like homework to me, so I'll say: read the sed manual


All times are GMT -5. The time now is 11:33 AM.