Posted By

willcodeforfood on 12/16/07


Tagged

sed


Versions (?)

SED by itself


 / Published in: Other
 

URL: http://snippets.dzone.com/posts/show/4894

http://snippets.dzone.com/posts/show/4894

  1. grep widget mlb | awk '{print $3}' | sed 's/-->/ /g'
  2.  
  3. sed sub --> with blank space g= global
  4.  
  5. # substitute "foo" with "bar" ONLY for lines which contain "baz"
  6. sed '/baz/s/foo/bar/g'
  7.  
  8. # substitute "foo" with "bar" EXCEPT for lines which contain "baz"
  9. sed '/baz/!s/foo/bar/g'
  10.  
  11. # change "scarlet" or "ruby" or "puce" to "red"
  12. sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds
  13. gsed 's/scarlet\|ruby\|puce/red/g'
  14.  
  15. Substitute newlines for &
  16. sed -e 's/&/\n/g' test.txt

Report this snippet  

You need to login to post a comment.