Im working on basic shell scripts, how do I get rid of the "-l6"
[EDIT] Added comments, the comments are added to the first script only because Im lazy and there the same in the second script [/EDIT]
//screen shots
[prompt]$ ./count4 -l6 -f1
-l6
1
2
3
4
5
6
[prompt]$ ./count4 -f1 -l6
1
2
3
4
5
6
-l6
[prompt]$
[b]//scipt file[b]
But if I use this script file I get the output following itCode:#!/bin/bash # ./count4 -f3 -l15 print 3 to 15 to screen if [ $1==-f* ] && [ $2==-l* ]; then #a becomes 3 a=${1#-f} #b becomes 15 b=${2#-l} while (($a<=$b)); do echo $a a=$(($a+1)) done fi #if ./count4 -l15 -f3 print 3 to 15 to screen if [ $1==-l* ] && [ $2==-f* ]; then #a becomes 3 a=${2#-f} #b becomes 15 b=${1#-l} while (($a<=$b)); do echo $a a=$(($a+1)) done fi
Code:#!/bin/bash if [ $1==-f* ] && [ $2==-l* ]; then a=${1#-f} b=${2#-l} while (($a<=$b)); do echo $a a=$(($a+1)) done elif [ $1==-l* ] && [ $2==-f* ]; then a=${2#-f} b=${1#-l} while (($a<=$b)); do echo $a a=$(($a+1)) done fi
[prompt]$ ./count4 -f1 -l6
1
2
3
4
5
6
[prompt]$ ./count4 -l6 -f1
-l6
[prompt]$



LinkBack URL
About LinkBacks


