Tuesday, March 18, 2008

sed

sed is a stream editor, which is used to perform basic text transformations on an input stream (a file or input from a pipeline). For example: find www.weisu.org in the files and replaced with www.weisu.org/blog, another one is replace and write to another file.
grep -r -l 'www.weisu.org' | sed -e 's/www.weisu.org/www.weisu'.org/blog/g'
grep -r -l 'Copyright' app.c | sed -e 's/Copyright/CopyRight/g' app.c > app2.c

[update: 2/20/2013]
grep  -rlw "crcSlow" . | xargs sed -i 's/crcSlow/MOT_crcSlow/'

No comments:

Post a Comment