Sed Command

find /home -type f -exec sed -i 's/word1/word2/g' {} \;

Replace the word1 to word2 in all the files under /home by command find + sed

cat abc.txt | sed 's/ //g'
cat abc.txt | sed 's/ abc/def/g'

remove all whitespace , replace the word1 to word2 to standard output

cat abc.html | sed 's/<[^>]*>//g'

remove all html tag

## add the words insert into 2nd line of file sed "1 a helloworld!" file > /tmp/file cp -av /tmp/file file rm -f /tmp/file



cat abc.txt | sed -n -e "/keyword/,/stopkeyword/ p"

Same as "grep" to find all relate line with keyword , but apply with "stop keyword" , eg: 123 start hello world end 456 starting hello world2 end2 789 run sed -n -e "/start/,/end/ p" it show : start hello world end starting hello world2 end2



Server is hosted by Alanstudio
Linux Operating System

Recommend screen resolution 1024 x 768 / IE / FireFox
Alan Studio © 2007 by Alan Cheung Hin Lun. All rights reserved.