LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices



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

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


Hi,
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 11:14 PM.
 
Old 03-21-2008, 11:22 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,501

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

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


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 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 07:30 AM
Can't permanently change path SuperRunt Linux - Newbie 11 02-03-2005 12:59 AM
Sed Command & Passing Values joey52 Linux - Newbie 4 12-27-2004 08:46 PM
can't change tcp_sack permanently kentri9 Linux - Networking 1 10-30-2004 06:20 PM
Permanently change the hostname juby Linux - Software 13 05-10-2003 01:34 PM


All times are GMT -5. The time now is 06:40 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