Skip to content

Instantly share code, notes, and snippets.

@coquin
Last active February 13, 2017 16:13
Show Gist options
  • Select an option

  • Save coquin/af23009158bb42164c4a2e63e35ff30e to your computer and use it in GitHub Desktop.

Select an option

Save coquin/af23009158bb42164c4a2e63e35ff30e to your computer and use it in GitHub Desktop.
Command line tools cheat sheet

sed

sed -i '' '/null/d' filename.txt — removes all strings containing null from a file filename.txt

wc

wc -l filename.txt — prints the number of lines in the file

searching for text in files (in current directory)

ack "text-to-find" .

grep -r "text-to-find" .

counting the number of matching lines

ack -c "text-to-find" .

grep -cr "text-to-find" .

NB: ack is generally much faster than grep

Renaming many files

Easy with rename: brew install rename

Rename files like output_01_01_2017.txt to output_2017_01_01.txt:

rename 's/output_(\d\d)_(\d\d)_(\d\d\d\d)\.txt/output_$3_$2_$1\.txt/' *

Simple HTTP server

python -m SimpleHTTPServer [port]

Starts a webserver on port port (default is 8000).

@coquin
Copy link
Copy Markdown
Author

coquin commented Jan 30, 2017

Need to create such a cheat sheet as I'm tired to google for same stuff from time to time.

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