Advertisement
Shishu

bash program

Nov 28th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. num1=1
  4. num2=10
  5. if [ $num1 -gt $num2 ]; then
  6.                echo "number  one is greather  "
  7. else
  8.          echo "number two is greater"
  9. fi
  10.  
  11.  
  12. @for comapre  number
  13. ...................................
  14. #!/bin/bash
  15.  
  16. num1=1
  17. num2=10
  18. if [ $num1 -eq $num2 ]; then
  19.                echo "number  is equel  "
  20. else
  21.          echo "not equel"
  22. fi
  23.  
  24. @for check odd or even number
  25. ......................
  26. #!/bin/bash
  27.  
  28. echo -n "please enter a number"
  29. read n
  30. check=$(($n % 2))
  31. if [ $check -eq 0 ];then
  32. echo "$n is an even number"
  33. else
  34. echo "$n is an odd number"
  35. fi;
  36. -------------------------------
  37. @for string comparisom
  38.  
  39.  
  40. #!/bin/bash
  41.  
  42. num1="jahid"
  43. num2="arif"
  44. if [ $num1 = $num2 ]; then
  45.                echo "name is equal  "
  46. else
  47.          echo "not equal"
  48. fi
  49. -----------------------
  50. @FOR counting
  51.  
  52. #!/bin/bash
  53.  
  54. COUNT=6
  55. while [ $COUNT -gt 0 ]; do
  56. echo value of count is: $COUNT
  57. let COUNT=COUNT-1
  58. done
  59. ----------------
  60. @ for reverse
  61. #!/bin/bash
  62.  
  63. COUNT=1
  64. while [ $COUNT -lt 7 ]; do
  65. echo value of count is: $COUNT
  66. let COUNT=COUNT+1
  67. done
  68.  
  69. -----------------------
  70. #!/bin/bash
  71.  
  72. COUNT=0
  73. until [ $COUNT -gt 5 ]; do
  74. echo value of count is: $COUNT
  75. let COUNT=COUNT+1
  76. done
  77. @ addition
  78.  
  79. echo '#### let ###'
  80. let addition=3+5
  81. echo "3+5 =" $addition
  82.  
  83. @subtraction
  84.  
  85. echo '#### let ###'
  86. let subtraction=5-3
  87. echo $subtraction
  88.  
  89.  
  90. @power of
  91. echo '#### let ###'
  92. let poweroftwo=2**2
  93. echo "2^ 2=" $poweroftwo
  94.  
  95. @mathmatatics
  96.  
  97. echo 2^8 =$[ 2** 8 ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement