Stripping off extensions for decompress() function
From: Michael Kipper (mkipper_at_rogers.com)
Date: 01/08/04
- Next message: Ursula Lee: "Help - UNIX Shell script problem"
- Previous message: Alan Connor: "Re: file processing"
- Next in thread: Alex Schuster: "Re: Stripping off extensions for decompress() function"
- Reply: Alex Schuster: "Re: Stripping off extensions for decompress() function"
- Reply: Chris F.A. Johnson: "Re: Stripping off extensions for decompress() function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 08 Jan 2004 01:52:29 GMT
Hello,
I am trying to write a decompress() function, which will untar a file into
/usr/src, regardless of the archive type
I'm new to bash, so if someone will help me translate this pseudocode
to bash script, that would be great:
decompress()
{
extension=`somefunction $1`
if (extension == "tar.gz") then
tar -zxf filename
else if (extension == "tar.bz2") then
tar -jxf filename
else if (extension == "bz2") then
bunzip2 filename
else if (extension == "gz") then
gunzip filename
}
There must be some function to do this properly, like `basename` or
something like it. Also, if there's a better way to do this, by all
means...
Thanks,
Michael Kipper
Toronto, Ontario
- Next message: Ursula Lee: "Help - UNIX Shell script problem"
- Previous message: Alan Connor: "Re: file processing"
- Next in thread: Alex Schuster: "Re: Stripping off extensions for decompress() function"
- Reply: Alex Schuster: "Re: Stripping off extensions for decompress() function"
- Reply: Chris F.A. Johnson: "Re: Stripping off extensions for decompress() function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|