Skip to content

Instantly share code, notes, and snippets.

@krasnobaev
Last active June 21, 2016 07:04
Show Gist options
  • Save krasnobaev/9bfb4da0b3b9cb846d974e6c26805a38 to your computer and use it in GitHub Desktop.
Save krasnobaev/9bfb4da0b3b9cb846d974e6c26805a38 to your computer and use it in GitHub Desktop.
MacOS sed patterns
# MacOS sed patterns difference – http://unix.stackexchange.com/a/131940/58019
sed /pattern/,+2d # like `sed '/pattern/{N;N;d;}'`
sed -n 0~3p # like `awk NR%3==0`
sed /pattern/Q # like `awk '/pattern/{exit}1'` or `sed -n '/pattern/,$!p'`
sed 's/\b./\u&/g' # \u converts the next character to uppercase
sed 's/^./\l&/' # \l converts the next character to lowercase
sed -i '1ecat file_to_prepend' file # e executes a shell command
sed -n l0 # 0 disables wrapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment