Last active
July 22, 2018 22:05
-
-
Save ouyi/62f998c8faa414a1fc2e760ab661b369 to your computer and use it in GitHub Desktop.
Frequently used sed commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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