The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-19-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

untested but it should get you pretty close
#!/bin/sh if [ $# -gt 26 ] then echo "Too many args!" exit 1 fi letters="a b c d e f g h i j k l m n o p q r s t u v w x y z" cli="myprog" count=1 operation="" for argument in $* do count=`expr $count + 1` letter=`echo $letters | head +$count | tail -1` cli="$cli -$letter ${argument}/${argument}.ext" if [ -z "$operation" ] then operation=$letter else operation="${operation}+${letter}" fi done cli="$cli -operation \"$operation\"" $cli
-->
Code:
#!/bin/sh
if [ $# -gt 26 ]
then
   echo "Too many args!"
   exit 1
fi

letters="a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z"
cli="myprog"
count=1
operation=""
for argument in $*
do
   count=`expr $count + 1`
   letter=`echo $letters | head +$count | tail -1`
   cli="$cli -$letter ${argument}/${argument}.ext"
   if [ -z "$operation" ]
   then
      operation=$letter
   else
      operation="${operation}+${letter}"
   fi
done
cli="$cli -operation \"$operation\""
$cli