Sed Flashcards

1
Q

Sed: how to prepend line of text to a file (at top)?

A

$ sed -i ‘1s/^/\n/’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sed: how to edit files in place?

A

-i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly