LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 05-08-2006, 06:36 AM   #1
vikrambhimbar
Member
 
Registered: Aug 2005
Location: India
Posts: 33

Rep: Reputation: 15
Need help to write Shell Script


Hi ,

Can Any one tell me how I will be able to overwrite specific line from a file using Shell script.

For Example
Suppose from /etc/passwd file if I have to find entry of any user say user "a" and modify it with some other value....But only the entry of user "a"....How should I do this,


Please help Me.

Thanks,
Vikram
 
Old 05-08-2006, 07:10 AM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
The easiest way to do it would be to use sed.
A sample:
Code:
cat /etc/passwd | sed 's/username.*/foouser:x:1111:111::\/home\/foouser:\/bin\/bash/'
Remember to escape the path slashes.. (:
 
  


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
help to write shell script vikrambhimbar Linux - Software 2 04-03-2006 05:43 AM
Where to write the shell script? OpenSesame Linux - Newbie 3 03-27-2006 03:03 PM
HELP:write a CGI program with shell script supermyself Programming 3 06-12-2005 04:10 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


All times are GMT -5. The time now is 07:36 PM.

Main Menu
Advertisement
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