Menu

gitpiper

sed Cheat Sheet in May 2024

Last Updated: 13 May 2024

README.md

In place replacements

In-place replacement (GNU)

sed -i -e 's/foo/bar/' example.md

In GNU sed: use -i without arg.

In-place replacement (BSD)

sed -i '' -e 's/foo/bar/' example.md

In OSX, -i '' is required.

File regions

{:.-three-column}

Print until a certain line is met

sed '/begin api/q'

Print until a certain line is met, but not that line

sed '/^# begin/,$d'

Print everything after a given line

sed -n '/end api/,$p'

Print after a given line is found.

Print everything except matching

sed -n '/regex/d;'

Print everything except lines matching regex. Useful for printing files with comments.


338+ more cheat sheets for you in May 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️