#!/bin/bash
# Linux Journal: Issue 177: 2009-January; Page 40
# example of how to handle both {,un}compressed files
function data_source ()
{
local F=${1%.gz}
# remove file extension
if [[ -f $F ]] ; then
cat "${F}"
elif [[ -f $F.bz2 ]] ; then
bunzip --stdout "${F}.bz2"
elif [[ -f $F.bz ]] ; then
bunzip --stdout "${F}.bz"
elif [[ -f $F.gz ]] ; then
gunzip --stdout "${F}.gz"
fi
}
find . -maxdepth 1 -type f -print | while read file;
do
data_source $file | less
done
syntax highlighted by Code2HTML, v. 0.9.1