Skip to main content

Posts

Showing posts from July, 2018

Unix Briefing

Variables x=3 y='Hello' Note: there should be no space in assigning variables. Print Variables: echo $x echo $y More accurate printing variables is double quote your variables echo "$x" echo "$y" You can print literal also with variables. echo "Value of variable x is $x" If  else statement x=5 y=7 if [[ $x -lt $y ]]; then echo "true" else echo "false" fi Note : For good practice, put condition in [[...]]. There is semi-colon ; after condition end. fi command indicates closing of if else statements. For comparison, use -lt,-gt, -le, -ge comparison parameters for good practice if ((x>y)); then --- this also works -- Try yourself Nested if else can be done with using elif command x=cool if [ "$x" = "cool" ] then     echo "Cool Beans" elif [ "$x" = "neat" ] then     echo "Neato