LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to edit a specific parameter in many files simultaneously (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-edit-a-specific-parameter-in-many-files-simultaneously-900727/)

zeusys 09-02-2011 08:39 AM

How to edit a specific parameter in many files simultaneously
 
Hi
I need to change following parameter in multiples files.It's hard to edit them one by one with vi.

Code:

enabled=1
I need to change this to :
Code:

enabled=0
I suppose that I have to use sed command to achieve this goal.But I don't know how I can save the output to separated files as they were.

Code:

sed 's/enabled=1/enabled=0/g' *
I use this,but output doesn't go to a separated file.Also I know about redirections.
Please guide me
thank you

grail 09-02-2011 08:41 AM

man sed will give you your answer.

schneidz 09-02-2011 10:21 AM

i would use a for loop to go thru each file and edit everything you want in an automated way:
Code:

for item in *
do
 sed 's/enabled=1/enabled=0/g' $item > $item.sed
 #mv $item.sed $item
done


Nylex 09-02-2011 10:59 AM

Quote:

Originally Posted by schneidz (Post 4459713)
Code:

sed 's/enabled=1/enabled=0/g' $item > $item.sed

You could of course use the -i option to edit in place.


All times are GMT -5. The time now is 09:59 PM.