Useful Bash Commands

04 Nov 2020

how many lines with a given extension?

find . -name "*.$1" | xargs wc -l| tail -n 1


To run this site locally

sudo gem install rails
sudo gem install jekyll
sudo gem install jekyll bundler
cd ~/desiredFolder

bundle init
bundle install
bundle add jekyll
bundle exec jekyll serve

To turn .enex notes from Evernote into .md files directly: evernote2md


To find all files containing a given expression. grep -rnw '/path/to/somewhere/' -e 'pattern'


Tar commands:

To extract a tarfile:

tar -xzf myfile.tar.gz

x for extract, z for zip, f for file. -v for verbose, is optional.

tar -czf new_name.tar.gz source_directory

c for create, z for zip, v for verbose (optional) and f for file.

Note that source comes after destination, like in a ASM instruction!


Basic sed use case

echo 'this-is-a-path' | sed 's/-/\//g' output: ` this/is/a/path `