Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- argument=1
- for n in "$@"
- do
- if [ -e $n ] 2>'/dev/null'
- then
- echo "Argument #$argument: nespravny vstup"
- ((++argument))
- continue
- fi
- echo "$n" | egrep "^(-)?[[:digit:]]*$" >'/dev/null'
- if [ $? -eq 0 ]
- then
- #je to cislo
- if [ $n -eq 0 ]
- then
- #0
- echo "Argument #$argument: 1"
- ((++argument))
- continue
- fi
- if [ $n -lt 0 ]
- then
- #0>
- echo "Argument #$argument: nedefinovano"
- ((++argument))
- continue
- fi
- if [ $n -gt 0 ]
- then
- #1 2 3
- fact=1
- for((i=1;i<=n;++i))
- do
- ((fact*=i))
- done
- echo "Argument #$argument: $fact"
- ((++argument))
- continue
- fi
- else
- #nie je to cislo
- echo "Argument #$argument: nespravny vstup"
- ((++argument))
- continue
- fi
- done
- exit $#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement