Sed Flashcards
1
Q
Sed: how to prepend line of text to a file (at top)?
A
$ sed -i ‘1s/^/\n/’
2
Q
Sed: how to replace all occurances of search with replace in file?
A
$ find ./ -type f | xargs sed -i ‘s/search/replace/g’
or
$ sed -i ‘s/search/replace/g’ filename
3
Q
Sed: how to edit files in place?
A
-i
4
Q
Sed: how to insert text after first line (before second)?
A
sed -i ‘2 i\JENKINS_HOME=/syna_volume/;’ /etc/init.d/jenkins