sed

stream editor for filtering and transforming text

copy
93
21
echo this is a test | sed 's/a/my/'Find and replace the string a with my

details |

copy
61
13
echo this is not a test | sed -e 's/not //' -e 's/test/another test/'Do multiple substitutions

details |

copy
43
12
sed '/test/ !d' myfileDelete all lines that do not contain the string test

details |

copy
33
13
echo test12345 | sed 's/\([a-z]*\).*/\1/'Grab the letters from test and delete the numbers

details |

copy
32
7
sed '3a Text to append' myfileAppend 'Text to append' after the third line

details |

copy
27
3
dd if=/dev/sda | sed 's/Marry/Sally/g' | dd of=/dev/sdaReplaces ever occurrence of Marry with Sally on the hard drive /dev/sda

details |

copy
21
2
cat myfile.txt | sed 5qOutput the first 5 line of myfile.txt

details |

copy
19
4
sed '1,/^$/ d' myfileDelete all lines before first blank line

details |

copy
17
6
echo "54321 test" | sed 's/[0-9]*/& &/'Repeat the first occurrence of any numbers

details |

copy
16
3
sed '/test/ d' myfiledelete all lines on myfile that contain the string test

details |

copy
15
copy
14
0
echo hi | sed 's/\(h\)\(i\)/\2\1/g'swap the characters h and i

6 years, 2 months ago examplenow 1 | details |

copy
10
1
Find and replace strings in OSXsed -i "" 's/find/replace/g' views.py

4 years, 10 months ago george 4 |

copy
9
2
sed '1,3 d' myfileDelete the first 3 lines from myfile.

details |

copy
5
0
sed -i 's/test/NewSTR/g' myfilereplace the string test with NewSTR in myfile

6 years, 2 months ago john2 0 | details |

copy
5
0
echo hi | sed 's/i/sometext&&&&&&&/'copy the char i and replace it with sometextiiiiiii

6 years, 2 months ago examplenow 1 | details |

copy
2
0
Replace all strings foo with barsed -i 's/foo/bar/g'Replace all occurrences of the string foo with bar

4 years, 11 months ago examplenow 1 |

copy
0
0
zipinfo -T storage | sort -nr -k 7 | sed 15q

source | details |