Skip to content

Instantly share code, notes, and snippets.

@Sardonyx001
Last active July 15, 2024 03:18
Show Gist options
  • Save Sardonyx001/6c820ef26d4f452c667411cd976d0f2e to your computer and use it in GitHub Desktop.
Save Sardonyx001/6c820ef26d4f452c667411cd976d0f2e to your computer and use it in GitHub Desktop.
Sed cheatsheet
# Removes all lines containing `string` from input.txt and prints the result to STDIN
sed '/string/d' input.txt
# Overwrites the file with the modification
sed '/string/d' input.txt > input.txt
# Overrite inplace (Doens't work wth GNU sed, only MacOS & BSD sed)
sed -i '' '/string/d' input.txt
# GNU sed version
sed -i '/string/d' input.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment