Skip to content

Instantly share code, notes, and snippets.

@ouyi
Last active July 22, 2018 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouyi/62f998c8faa414a1fc2e760ab661b369 to your computer and use it in GitHub Desktop.
Save ouyi/62f998c8faa414a1fc2e760ab661b369 to your computer and use it in GitHub Desktop.
Frequently used sed commands
# Remove trailing whitespaces using sed
sed -i 's/[ \t]*$//' input_file
# Append line after pattern matching
sed -i "/mypattern.*/a 'my new stuff'" input_file
# Print the 2nd line
sed -n '2p' input_file
# Remove the last line
sed -i '$ d' foo.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment