LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 10:13 PM   #1
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Rep: Reputation: 39
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 10:14 PM.
 
Old 03-21-2008, 10:22 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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, 01:17 PM   #3
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:57 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
Open Source Consulting | Domain Registration