Skip to content

Instantly share code, notes, and snippets.

@oskarhagberg
Created July 1, 2011 12:08
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 oskarhagberg/1058415 to your computer and use it in GitHub Desktop.
Save oskarhagberg/1058415 to your computer and use it in GitHub Desktop.
Bash tricks

Useful bash commands

If you wanna find files that includes any occurrence of some text

find . -name <filename> -exec grep -Hn <occurrence> '{}' \;

Extracting (untar) archives

Extract a *.tar file using option xvf

Extract a tar file using option x as shown below:

$ tar xvf archive_name.tar
  • x – extract files from archive

Extract a gzipped tar archive ( *.tar.gz ) using option xvzf

Use the option z for uncompressing a gzip tar archive.

$ tar xvfz archive_name.tar.gz

Extracting a bzipped tar archive ( *.tar.bz2 ) using option xvjf

Use the option j for uncompressing a bzip2 tar archive.

$ tar xvfj archive_name.tar.bz2

Note: In all the above commands v is optional, which lists the file being processed.

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