I have the following code that print certain files in my directory and groups things together. I would be good to tidy and simplify this code up and would greatly appreciate suggestions.
if ($opt_raytrac == 1) then
echo ""
echo -n "\033[2;34m"
echo "-- Browse files for raytrac program -------------------------------------------------------"
echo -n "\033[m"
echo ""
echo " Looking in directory $pth"
echo ""
echo -n "\033[2;34m"
echo "-- Base files -----------------------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.base" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo -n "\033[2;34m"
echo "-- Sources files --------------------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.sr" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo -n "\033[2;34m"
echo "-- Receivers files ------------------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.rc" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
echo "\n $path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn"
endif
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo -n "\033[2;34m"
echo "-- Sound speed files ----------------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.cmd" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
# find $pth -maxdepth 1 -name "*.cmd" ! -regex '.*/\..*' -type f -print | sed 's/^.*\///' \
# | sed 's/\([0-9][0-9.]*\)/ & /g' | sort -k 4n | sed 's/ //g' \
# | awk -F- '{ c=($2!=p && FNR!=1)?ORS:""; p=$2 } { printf("%c%s\n",c,$0) }'
echo ""
echo -n "\033[2;34m"
echo "-- Ray path files -------------------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.ry" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo -n "\033[2;34m"
echo "-- Travel time list files -----------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.xt" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo -n "\033[2;34m"
echo "-- Travel time data files -----------------------------------------------------------------"
echo -n "\033[m"
echo ""
set fileLst = `find $pth -maxdepth 1 -name "*.tdat" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif
echo ""
exit 0
endif
---------- Post updated at 01:03 PM ---------- Previous update was at 10:20 AM ----------
I am thinking of a way forward and considering this proposal:
I create a series of list with the specific search criteria -
set fileLst1 = `find $pth -maxdepth 1 -name "*.base" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
set fileLst2 = `find $pth -maxdepth 1 -name "*.sr" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
set fileLst3 = `find $pth -maxdepth 1 -name "*.rc" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
set fileLst4 = `find $pth -maxdepth 1 -name "*.cmd" ! -regex '.*/\..*' -type f -print \
| sed 's/^.*\///'`
... etc
Then I perform a foreach loop to process
if (${%fileLst} > 0) then
if ($opt_chkColPos == 1) then
if ($vrbLevel > 1) then
echo "\n $path_tcsh/printTable.tcsh --chk-ColPos"
endif
$path_tcsh/printTable.tcsh --check $fileLst
else if ($opt_sortFlds == 1) then
if ($opt_groupTbl == 1) then
if ($vrbLevel > 1) then
echo "\n $path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn"
endif
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn --group=$groupPtn $fileLst
else
if (($opt_verbose == 1) && ($vrbLevel >= 3)) then
echo "\n $path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn"
endif
$path_tcsh/printTable.tcsh --shift=3 --sort=$sortPtn $fileLst
endif
endif
endif