Skip to content

Instantly share code, notes, and snippets.

@binshengliu
Created June 16, 2020 00:53
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 binshengliu/98187763c118c9a86dee8a06d0dd4142 to your computer and use it in GitHub Desktop.
Save binshengliu/98187763c118c9a86dee8a06d0dd4142 to your computer and use it in GitHub Desktop.
Prepend line number and a tab to each line
# Number each line
cat FILE | sed -r 's/^[[:space:]]*//' | awk '{print NR, "\t", $0}'
# Remove empty lines and number
cat FILE | sed -r 's/^[[:space:]]*//' | grep -v '^$' | awk '{print NR, "\t", $0}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment