#!/bin/bash

# Smart cat: calls cat, zcat, or bzcat on each of a list of files, as
# appropriate.

for file in $@; do
    text=$(file -L $file)
    if [[ $text =~ "gzip" ]]; then
        gzip -cd $file
    elif [[ $text =~ "bzip2" ]]; then
        bzcat $file
    else
        cat $file
    fi
done
