Skip to content

Instantly share code, notes, and snippets.

@rytoj
Last active October 20, 2015 15:33
Show Gist options
  • Save rytoj/1e90b160d302260ccbb1 to your computer and use it in GitHub Desktop.
Save rytoj/1e90b160d302260ccbb1 to your computer and use it in GitHub Desktop.
#Test for less than 1 parameter
if (( $# < 1));then
echo "Usage $0 <name>"
exit 1
fi
echo "Hello $1"
exit 0
######################################################
#Ingrementinimas per argumentus kartu so for loopu
#./test.sh pirmas antras
count=1
#Seka iki 10 su 'seq' komanda
#for x in $(seq 1 10)
for x in $*
do
if [ $count -lt 2 ] ;then
echo $x" yra zmogus"
else
echo $x" yra hakeris"
fi
#arba ((count++))
count=`expr $count + 1 `
done
######################################################
#While loop'as
COUNT=5
while (( COUNT > 0 ))
do
echo -e "$COUNT \c"
sleep 1
(( COUNT -- ))
done
echo -e "\nPabaiga"
######################################################
#exit parametro tikrinimas
if (( $? )); then
{
echo kaida $?;
exit;
}
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment