Navigation

sed

SED examples

sed '/^$/d' $file # remove empty lines
sed 's/replace/perpleaxed/g' # replace text
var=`echo "Hello\,World" | sed 's/\\\,/,/'`; echo $var --> "Hello,World" # remove backslash
sed -n 'H; /^CHECK/h; ${g;p;}' f1.txt # sed print from last occurrence match until the end of file
sed -n '/<pattern>/,$ p' <file> # from pattern to end of file
sed -n '/<pattern1>/,/<pattern2>/ p' <file> # from pattern1 to pattern2
sed -n '1,/<pattern>/ p' <file> # print from the first line until pattern is matched
Subscribe to sed