Skip to content

Instantly share code, notes, and snippets.

@robdecker
Last active February 19, 2020 01:01
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 robdecker/dfc6a2f0c05cf9719e4e369bd233c43f to your computer and use it in GitHub Desktop.
Save robdecker/dfc6a2f0c05cf9719e4e369bd233c43f to your computer and use it in GitHub Desktop.
[Delete lines from file] #sh

Delete particular line

  • This removes the second line in a file.
  • The d option in sed command is used to delete a line.
sed -i '2d' file

MacOS

The built-in BSD sed is different than GNU sed and has different options.

brew install gnu-sed

Then create an alias so gnu-sed is always used:

alias sed=gsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment