Skip to content

Instantly share code, notes, and snippets.

@cemdrman
Created October 3, 2022 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemdrman/cdb8847e88c8b3da26a7e7565aedab8a to your computer and use it in GitHub Desktop.
Save cemdrman/cdb8847e88c8b3da26a7e7565aedab8a to your computer and use it in GitHub Desktop.
Shell Script
#!/bin/bash
#special variables
echo $0
echo $n
echo $#
echo $*
echo $@
echo $?
echo $$
echo $!
echo $USER
echo $HOSTNAME
echo $SECONDS
echo $RANDOM
echo $LINENO
#variables
firm="hepsiemlak"
echo $firm
echo "enter your name:"
read name
echo "enter your age:"
read age
echo "name: $name - age: $age"
read -p "team name:" team_name
echo $team_name
#operatörs
let sum=28+8
echo $sum
let "sub=28-8"
echo $sub
echo $sub++
echo STRING1 = STRING2 STRING1 is equal to STRING2
echo STRING1 != STRING2 STRING1 is not equal to STRING2
echo INTEGER1 -eq INTEGER2 INTEGER1 is numerically equal to INTEGER2
echo INTEGER1 -gt INTEGER2 INTEGER1 is numerically greater than INTEGER2
echo INTEGER1 -lt INTEGER2 INTEGER1 is numerically less than INTEGER2
#arrays
team=("alper" "sema" "ufuk" "batuhan")
team[4]="cem"
team[5]="mert"
team[6]="akın"
team[7]="gökhan"
team[8]="arzu"
echo "Tech lead: ${team[0]}"
echo "team : ${team[*]}"
echo "team : ${team[@]}"
#loops
for member in ${team[@]}
do
echo "team member: " $member
done
echo "loop with if else statements"
for member in ${team[@]}
do
if [ $member = ${team[0]} ] # string equal
then
echo "tech lead: " $member
else
echo "team member: " $member
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment