Code:
#!/bin/csh
set iarg = 0
set optlegend = 0
set nf = 0
set Version = "V04"
alias MATH 'set \!:1 = `echo "\!:3-$" | bc -l`'
set narg = $#argv
while ($iarg < $narg)
MATH iarg = $iarg + 1
set arg = $argv[$iarg]
set opt = ` echo $arg | awk 'BEGIN { FS="=" } { print $1 }' \
| tr "[A-Z]" "[a-z]" `
set par = ` echo $arg | awk 'BEGIN { FS="=" } { print $2 }' `
switch ($opt)
case "-legend":
set Alegend = $par
set legend = $Alegend
breaksw
default:
set filename = `echo $arg | awk 'BEGIN {FS="."} {print $1}'`
set filextension = `echo $arg | awk 'BEGIN {FS="."} {print $2}'`
set nxz = `echo $filename | awk 'BEGIN{FS="-"} {print $NF}'`
echo "File = $filename"
set fullnames = "$fullnames $arg" # Store the file names
set fnames = "$fnames $filename" # Store the file names
set fext = "$fext $filextension" # Store the file extensions
MATH nf = $nf + 1
endsw
end # while
set fin = ($fnames)
set fout = "fout"
if ($nf == 1) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend = ($legend1)
echo " $nf. $legend"
else if ($nf == 2) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend = ($legend1 $legend2)
echo " $nf. $legend"
else if ($nf == 3) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend = ($legend1 $legend2 $legend3)
echo " $nf. $legend"
else if ($nf == 4) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend = ($legend1 $legend2 $legend3 $legend4)
echo " $nf. $legend"
else if ($nf == 5) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5)
echo " $nf. $legend"
else if ($nf == 6) then
set fname = $fsmp6
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend6 = `echo $Alegend | awk '{split($1,a,"/"); print a[6]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5 \
$legend6)
echo " $nf. $legend"
else if ($nf == 7) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend6 = `echo $Alegend | awk '{split($1,a,"/"); print a[6]}'`
set legend7 = `echo $Alegend | awk '{split($1,a,"/"); print a[7]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5 \
$legend6 $legend7)
echo " $nf. $legend"
else if ($nf == 8) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend6 = `echo $Alegend | awk '{split($1,a,"/"); print a[6]}'`
set legend7 = `echo $Alegend | awk '{split($1,a,"/"); print a[7]}'`
set legend8 = `echo $Alegend | awk '{split($1,a,"/"); print a[8]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5 \
$legend6 $legend7 $legend8)
echo " $nf. $legend"
else if ($nf == 9) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend6 = `echo $Alegend | awk '{split($1,a,"/"); print a[6]}'`
set legend7 = `echo $Alegend | awk '{split($1,a,"/"); print a[7]}'`
set legend8 = `echo $Alegend | awk '{split($1,a,"/"); print a[8]}'`
set legend9 = `echo $Alegend | awk '{split($1,a,"/"); print a[9]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5 \
$legend6 $legend7 $legend8 $legend9)
echo " $nf. $legend"
else if ($nf == 10) then
set legend1 = `echo $Alegend | awk '{split($1,a,"/"); print a[1]}'`
set legend2 = `echo $Alegend | awk '{split($1,a,"/"); print a[2]}'`
set legend3 = `echo $Alegend | awk '{split($1,a,"/"); print a[3]}'`
set legend4 = `echo $Alegend | awk '{split($1,a,"/"); print a[4]}'`
set legend5 = `echo $Alegend | awk '{split($1,a,"/"); print a[5]}'`
set legend6 = `echo $Alegend | awk '{split($1,a,"/"); print a[6]}'`
set legend7 = `echo $Alegend | awk '{split($1,a,"/"); print a[7]}'`
set legend8 = `echo $Alegend | awk '{split($1,a,"/"); print a[8]}'`
set legend9 = `echo $Alegend | awk '{split($1,a,"/"); print a[9]}'`
set legend10 = `echo $Alegend | awk '{split($1,a,"/"); print a[10]}'`
set legend = ($legend1 $legend2 $legend3 $legend4 $legend5 \
$legend6 $legend7 $legend8 $legend9 $legend10)
echo " $nf. $legend"
endif
endif