Skip to content

Instantly share code, notes, and snippets.

@ouyi
Last active Jul 22, 2018
Embed
What would you like to do?
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