Acclaimed Contributor Acclaimed Contributor
Re: Finding file extension
It would be helpful if you provided a few examples but something like this:

cp *.gz /xxx/yyy/gzdir/
cp *.dat /xxx/yyy/tardir/

Note: UNIX has no concept of a file extension; that belongs to another OS.

If you wish to strip off a suffix then something like this:

#!/usr/bin/sh

typeset BASE=""
typeset FNAME=""
typeset SUFFIX=".gz"

ls | while read FNAME
do
BASE=$(basename "${FNAME}" "${SUFFIX}")
if [[ "${BASE}" != "${FNAME}" ]]
then
echo "Basename: ${BASE}"
# do your copy here
fi
done

------------------------------------
You only see the base part of the filename with the suffix stripped off. Files not matching the suffix are ignored. Man basename for details.
If it ain't broke, I can fix that.