Linux shell bulk edit using SED editor
Posted by
Jiltin 17 December, 2008 925 views
- Linux / Unix: sed – How to replace text in multiple files?
- Textpad how to change the colour of searching text? Regex Samples
- How To Write A Unix / Linux Shell Function, Embed With .bashrc To Use It?
- Linux / Unix / Bash Functions: How do I set the BASH functions in .bashrc and use it after login?
- How do I Grep (unix, Linux) to match either of two strings?
Question:
I generally use Perl for this
ex.
perl -e ’s/pattern/replace/g’ -p -i <filename>
I did something like this..
find . -type f -exec perl -e ’s/pattern/replace/g’ -p -i {} \;
I want to do this with “sed”
but what I get is the output being printed on the screen..
I can do
sed -e ’s/pattern/replace/g’ < input > output
but in my case of “find”, i dont want to create a bunch of output files, rather the editing to take place in the same file..
Any ideas?
Answer
grep -il pattern *‘ xargs sed -i ‘s/pattern/replace/g‘
Have your comment, if this is helping you.
Following Google Searches Lead To This Post:
sed bulk edit files
Categories :
Scripts Unix

Comments
No comments yet.