#!/bin/sh
#
# Generates a list of files with absolute path.
#
# Usage: ./gpl [files] > pcap_list.txt
#
# find DIR -type f -exec file {} \; | grep -i " capture file " | cut -d: -f1 > pcap_list.txt

if [ $# -gt 0 ]; then
    PCAP=$*;
else
    PCAP="."
fi

if [ -d "$PCAP" ]; then
    PCAP="$PCAP/"*
fi

for i in $PCAP; do
    if [ -f "$i" ] && [ ! -z "$(file "$i" | grep -i ' capture file ')" ]; then
        echo "$(readlink -f "$i")";
    fi
done
