Tag Archives: command

A bash script for Linux to extract all kind of compressed file from console.

Open ~/.bashrc file with your favorite editor and paste below script to the bottom of the file.

extract () {
if [ -f $1 ] ; then
    case $1 in
     *.tar.bz2) tar xvjf $1 ;;
     *.tar.gz) tar xvzf $1 ;;
     *.bz2) bunzip2 $1 ;;
     *.rar) rar x $1 ;;
     *.gz) gunzip $1 ;;
     *.tar) tar xvf $1 ;;
     *.tbz2) tar xvjf $1 ;;
     *.tgz) tar xvzf $1 ;;
     *.zip) unzip $1 ;;
     *.Z) uncompress $1 ;;
     *.7z) 7z x $1 ;;
    *) echo "don't know how to extract '$1'..." ;;
   echo "'$1' is not a valid file!"

then write "extract" on console with the file you want to extract and see the effect.

extract bla.tar.gz

Creating Custom Linux Command

Sometimes you may need to repeat lots of linux command on terminal for any aim. It is some time so boring to type all the commands again and again so the solution to create  own commands to execute all the repetition in one.

All the commands are kept on /bin directory s we just need to create a file and name as the command that we'll use. Then we need to make the file readable and executable. Continue reading Creating Custom Linux Command