#!/bin/sh

if [ "$1" = "" ]; then
files="1"
else
files=$1
fi

ls -rt /home/echidna2/ss/tmp/echidna/guiNFSDir/*.pgm | tail -${files} > tmp_conv1.tbl
cut -c41- tmp_conv1.tbl | sed -e 's/pgm/fits/g' > tmp_conv2.tbl
sed -e 's/\/home/convert \/home/g' tmp_conv1.tbl > tmp_conv3.tbl
paste -d" " tmp_conv3.tbl tmp_conv2.tbl > tmp_conv4.tbl
sh < tmp_conv4.tbl
cat tmp_conv2.tbl
\rm tmp_conv?.tbl
