BetinaUKTC

testzadachi

Jan 24th, 2022
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.10 KB | None | 0 0
  1. ////////////////////////////////3.1/////////////////////////////////////
  2. #! /bin/bash
  3.  
  4. sum=0;
  5. for n in $@
  6. do
  7.   sum=$(expr $sum + $n)
  8. done
  9. echo $sum
  10. ////////////////////////////////3.2/////////////////////////////////////
  11. #! /bin/bash
  12.  
  13. min=100000000;
  14. for n in $@
  15. do
  16.   if [ "$n" -lt "$min" ]
  17.   then
  18.   min=$n
  19. fi
  20. done
  21. echo $min
  22. ////////////////////////////////3.3/////////////////////////////////////
  23. #! /bin/bash
  24.  
  25. max=-100000000;
  26. for n in $@
  27. do
  28.   if [ "$max" -lt "$n" ]
  29.   then
  30.   max=$n
  31. fi
  32. done
  33. echo $max
  34. ////////////////////////////////3.4/////////////////////////////////////
  35. #! /bin/bash
  36.  
  37. echo &ls -1 | wc -l
  38. ////////////////////////////////3.5/////////////////////////////////////
  39. #! /bin/bash
  40.  
  41. if [ "$1" = "-n" ]
  42. then
  43. echo $USER
  44. fi
  45.  
  46. if [ "$1" = "-l" ]
  47. then
  48. echo &pwd
  49. fi
  50.  
  51. if [ "$1" = "-t" ]
  52. then
  53. echo &date
  54. fi
  55.  
  56. if [ "$1" = "-c" ]
  57. then
  58. echo &cal
  59. fi
  60. ////////////////////////////////3.6/////////////////////////////////////
  61. i=$1
  62. while [ "$i" -gt 0 ];
  63.     do
  64.     echo $2
  65.     i=$(( i - 1 ))
  66. done
  67. ////////////////////////////////3.7/////////////////////////////////////
  68. a=$2
  69. b=$3
  70.  
  71. if [ "$1" = "-s" ]
  72. then
  73. echo $(expr $a + $b)
  74. fi
  75.  
  76. if [ "$1" = "-m" ]
  77. then
  78. echo $(( a < b ? a : b ))
  79. fi
  80.  
  81. if [ "$1" = "-M" ]
  82. then
  83. echo $(( a > b ? a : b ))
  84. fi
  85.  
  86. if [ "$1" = "-a" ]
  87. then
  88. sum=$(expr $a + $b)
  89. avg=`echo "$sum / $2" | bc -l`
  90. echo $avg
  91. fi
  92. ////////////////////////////////3.8/////////////////////////////////////
  93. #! /bin/bash
  94.  
  95. i=$1
  96. while [ "$i" -gt 0 ]; do
  97.     echo $2
  98.     i=$(( i - 1 ))
  99. done
  100. ////////////////////////////////3.9/////////////////////////////////////
  101. #! /bin/bash
  102.  
  103. filename=$1
  104. touch ${filename}.txt
  105.  
  106. if [ "$2" = "-n" ]
  107. then
  108. $USER >> ${filename}.txt
  109. fi
  110.  
  111. if [ "$2" = "-l" ]
  112. then
  113. pwd >> ${filename}.txt
  114. fi
  115.  
  116. if [ "$2" = "-t" ]
  117. then
  118. date >> ${filename}.txt
  119. fi
  120.  
  121. if [ "$2" = "-c" ]
  122. then
  123. cal >> ${filename}.txt
  124. fi
  125. ////////////////////////////////3.10/////////////////////////////////////
  126. #! /bin/bash
  127.  
  128. filename=$1
  129. touch ${filename}.txt
  130.  
  131. sum=$(expr $2 + $3)
  132. avg=`echo "$sum / 2" | bc -l`
  133.  
  134. printf "%.2f" $avg >> ${filename}.txt
Advertisement
Add Comment
Please, Sign In to add comment