A single command to install almost anything in linux from source

After going through many source files in Linux , most of them are tarballs.

The formats in general practice are :

# ".tgz" is equivalent to ".tar.gz".
# ".tbz" (or ".tbz2" or ".tb2") is equivalent to ".tar.bz2".
# ".taz" is equivalent to ".tar.Z",
# ".tlz" is equivalent to ".tar.lzma"

Out of which , 90% of them will be .tar.gz or .tar.bz2.

Considering them , here is a command which can be used to install application :

# URL is the Application URL

For source with tar.bz2 :

IF the /url/*.[tar.bz2] , get the last part of the url that is *.[tar.bz2]

For example : "http://../h3manth.tar.gz"
The last part is h3manth.tar.gz

sudo wget "URL" && bzip2 -cd h3manth.tar.bz2 | tar xvf - && cd h3manth && ./configure && make && sudo make install

For source with tar.gz :

sudo wget -qO - "http://www.tarball.com/tarball.gz" | tar zx && cd tarball && ./configure && make && sudo make install

P.S : Please read the ./configure doesn't work , go for ./configure --prefix=/usr --sysconfdir=/etc or do the configurations as suggested in the URL , from where you are getting your source.

There are always more ways to do the same , this is one of the methods more suggestions for improvement is always welcomed.

P.S : Based on your requirements , the below method may be useful :

url="http://nmap.org/dist/nmap-5.00.tar.bz2"

echo $url | grep -oE '[^/]*\.tar\.(gz|bz2)'

nmap-5.00.tar.bz2

Rather again in one line it would be :
url="http://nmap.org/dist/nmap-5.00.tar.bz2" ;dir=(`echo $url | grep -oE '[^/]*\.tar\.(gz|bz2)'`)

using $dir , would give you "nmap-5.00.tar.bz2"

Share this