LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-02-2008, 05:19 AM   #1
kaash_m31
LQ Newbie
 
Registered: Jun 2008
Posts: 1

Rep: Reputation: 0
Question 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.

Last edited by kaash_m31; 06-02-2008 at 05:20 AM.
 
Old 06-02-2008, 05:36 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756
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/
 
Old 06-02-2008, 05:43 AM   #3
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you edit a file in shell? Jhorra Linux - Newbie 3 03-11-2007 12:34 AM
Bash script to edit text file snowman81 Linux - Desktop 2 01-10-2007 03:33 PM
Help with a script to edit text file (awk? sed?) rickh Linux - Newbie 8 04-21-2005 08:24 PM
change login shell in mac os x, which file to edit feetyouwell Linux - Software 5 02-28-2004 06:23 PM
script edit file.. johnyy Linux - Software 4 01-22-2004 05:50 PM


All times are GMT -5. The time now is 04:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration