Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


Search this Thread
Old 03-21-2008, 10:13 PM   #1
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 489

Rep: Reputation: 37
sed to change some values in a file permanently

I have a file where I there are some 1500 lines and in there I want to change some values. For that I am using sed like below:

PHP Code:
cat /home/test.css grep "network.type” | sed –i ‘s/0/1/’ 
Now the problem is it changes the lines in file but how to make it permanent and if I use sed with -i option then I have to provide the file name with it but I am using grep to grep the line.

Any clue please.

Last edited by tanveer; 03-21-2008 at 10:14 PM.
Old 03-21-2008, 10:22 PM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,229

Rep: Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019
You don't need cat, nor grep - use sed's address facility (see the manpage). Something like this
sed -i /network.type/s/0/1' test.css
Old 03-23-2008, 01:17 PM   #3
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 489

Original Poster
Rep: Reputation: 37
Thanks a lot. just what I was looking for.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
change file permission of a mouse device file permanently alexandre_fs Linux - General 5 01-09-2007 06:30 AM
Can't permanently change path SuperRunt Linux - Newbie 11 02-02-2005 11:59 PM
Sed Command & Passing Values joey52 Linux - Newbie 4 12-27-2004 07:46 PM
can't change tcp_sack permanently kentri9 Linux - Networking 1 10-30-2004 05:20 PM
Permanently change the hostname juby Linux - Software 13 05-10-2003 12:34 PM

All times are GMT -5. The time now is 07:27 AM.

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