How do I find the number of arguments passed to a Bash script?
This is what I have currently:
#!/bin/bash i=0 for var in \"$@\" do i=i+1 done
Below is the easy one -
cat countvariable.sh
echo "$@" |awk '{for(i=0;i<=NF;i++); print i-1 }'
Output :
#./countvariable.sh 1 2 3 4 5 6 6 #./countvariable.sh 1 2 3 4 5 6 apple orange 8