Database Reference
In-Depth Information
if [[ -z "$@" ]] ; then
echo " ${0##*/} <archive> - extract common file formats)"
exit
fi
# Required program(s)
req_progs =( 7z unrar unzip )
for p in ${ req_progs [@] } ; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed." ; exit 1; }
done
# Test if file exists
if [ ! -f "$@" ] ; then
echo "File " $@ " doesn't exist"
exit
fi
# Extract file by using extension as reference
case "$@" in
*.7z ) 7z x "$@" ;;
*.tar.bz2 ) tar xvjf "$@" ;;
*.bz2 ) bunzip2 "$@" ;;
*.deb ) ar vx "$@" ;;
*.tar.gz ) tar xvf "$@" ;;
*.gz ) gunzip "$@" ;;
*.tar ) tar xvf "$@" ;;
*.tbz2 ) tar xvjf "$@" ;;
*.tar.xz ) tar xvf "$@" ;;
*.tgz ) tar xvzf "$@" ;;
*.rar ) unrar x "$@" ;;
*.zip ) unzip "$@" ;;
*.Z ) uncompress "$@" ;;
* ) echo " Unsupported file format" ;;
esac
Now, in order to decompress this same file, you would simply use:
$ unpack logs.tar.gz
Converting Microsoft Excel Spreadsheets
For many people, Microsoft Excel offers an intuitive way to work with small data sets
and perform calculations on them. As a result, a lot of data is embedded into Micro‐
soft Excel spreadsheets. These spreadsheets are, depending on the extension of the
filename, stored in either a proprietary binary format ( .xls ) or as a collection of com‐
pressed XML files ( .xlsx ). In both cases, the data is not readily usable by most
command-line tools. It would be a shame if we could not use those valuable data sets
just because they are stored this way.
Search WWH ::




Custom Search