Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts

Monday, June 1, 2009

Inserting a blank line with sed

#I found this to be a bit tricky

sed -e '/pattern/i\
\ # <-- this is the key
' input_file > output_file

Friday, May 29, 2009

Removing carriage returns with sed

sed -e s/$'\r'/\ /g input_file # remove carriage returns

sed -e 's/\n/ /g' input_file # remove newlines

Insert text before a pattern with sed

cat some_file | sed '/pattern/i\
text to insert
' > output_file