Unix give you many opportunities to sort out this. Try having a look at man-pages for awk, sed, cut, paste, printf or simply the shells.
NB! this is /bin/sh syntax.
Always start your shells by specifying the shell you want to use like this: #!/bin/sh
You can do it very simple by using variable substitution directly available in the shell.
#removing first part of FILENAME
SHORTNAME=${FILENAME##load_jde_apexon_}
#trick is: search variable=FILENAME ##=until/incl.pattern
#same result: SHORTNAME=${FILENAME##*xon_}
#using wildchar
#removing last part of SHORTNAME
SHORTNAME=${SHORTNAME%%.log}
#trick is: search variable=SHORTNAME %%=from/incl. pattern
I suppose you get the filenames by using ls
example: ls -1 load_*_apexon_*
or simply: ls -1
Then you can read the filenames into a variable, one by one, and handle them.
example:
ls -1 | while read FILENAME
do
echo "File $FILENAME "
done
You can take different action depending on parts of filename:
case $FILENAME in
load_jde_apexon_*.log)
print 'Load log for JDE/Apexon job: \c'
SHORTNAME=${FILENAME##load_jde_apexon_}
SHORTNAME=${SHORTNAME%%.log}
print $SHORTNAME
if [ "$SHORTNAME" = "po_purchase_order_del_sched" ];then
tail $FILENAME
fi
;;
*) #do nothing
;;
esac