Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

bash

a guest Jun 13th, 2018 64 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. Bash Lab1
  2. 1:
  3. if [ "$#" -ne 1 ]; then
  4.     echo "Zle argumenty"
  5.     exit 1
  6. fi
  7. cat $1
  8. 2:
  9. if [ "$#" -ne 1 ]; then
  10.     echo "./zad1_2.sh arg1"
  11.     exit 1
  12. fi
  13. echo "Witaj" $1
  14. 3:
  15. if [ "$#" -ne 1 ]; then    
  16.     echo "Witaj" $USER
  17.     exit 1
  18. fi
  19. echo "Witaj" $1
  20. 4:
  21. cat /etc/passwd
  22. 5:
  23. if [ "$#" -ne 1 ]; then
  24.     echo "./zad1_5.sh folder"
  25.     exit 1
  26. fi
  27. if [ ! -d $1 ]; then
  28.     echo "Nie ma folderu"
  29.     exit 1
  30. fi
  31. tar -zcf $1_$(date +%d-%m-%Y_%H-%M) $1
  32. 6:
  33. if [ "$#" -ne 2 ]; then
  34.     echo "./zad1_6.sh tryb1/2 plik"
  35.     exit 1
  36. fi
  37. if [ "$1" -eq 1 ]; then
  38.     cat -n $2
  39.     exit 1
  40. elif [ "$1" -eq 2 ]; then
  41.     cat -n $2 | tac
  42.     exit 1
  43. else
  44.     echo "1 albo 2"
  45. fi
  46. 7:
  47. if [ "$#" -eq 0 ]; then
  48.     echo "./zad1_7.sh plik1 plik2 ... plikn"
  49.     exit 1
  50. fi
  51. for i in $@
  52. do
  53.     echo $i:
  54.     cat $i
  55. done
  56. Bash Lab2
  57. 1:
  58. for i in $(find . -name "*.sh" -type f); do
  59.     if [ "$(head -1 ${i})" == "#!/bin/bash" ]; then
  60.         echo "Plik '${i}'' posiada prawidlowa sciezke do interpretera"
  61.     else
  62.         echo "Plik '${i}'' nie posiada prawidlowej sciezki do interpretera"
  63.     fi
  64. done
  65. 2:
  66. if [ "$#" -ne 1 ]; then
  67.     echo "./zad2_2.sh rozmiar"
  68.     exit 1
  69. fi
  70. for ((i=1; $i <= $1; i++)); do
  71.     for ((j=1; $j <= $1; j++)); do
  72.         ((wynik = $i * $j))
  73.         echo "$i * $j = $wynik"
  74.     done
  75. done
  76. 3:
  77. if [ "$#" -ne 1 ]; then
  78.     echo "./zad2_3.sh katalog"
  79.     exit 1
  80. fi
  81. for i in $(find $1 -type f); do
  82.     if test -x $i; then
  83.         ./$i
  84.     fi
  85. done
  86. 4:
  87. var=0
  88. while read -r x; do
  89.     if [ ${#x} -gt $var ]; then
  90.         var=${#x}
  91.         t=$x
  92.     fi
  93. done
  94. echo $var: $t
  95. 5:
  96. if [ "$#" -lt 2 ]; then
  97.     echo "./zad2_5.sh zrodlo plik1 plik2 .. plikn"
  98. fi
  99. for i in $@; do
  100.     cp $1 $i
  101. done
  102. 6:
  103. if [ "$#" -lt 2 ]; then
  104.     echo "./zad2_6.sh liczba1 liczba2"
  105.     exit 1
  106. fi
  107. a=$1
  108. b=$2
  109. while [ $a -ne $b ]; do
  110.     if [ $a -gt $b ]; then
  111.         ((a=$a-$b))
  112.     else
  113.         ((b=$b-$a))
  114.     fi
  115. done
  116. echo $a
  117. 7:
  118. if [ "$#" -lt 2 ]; then
  119.     echo "./zad2_7 kwota piniondz"
  120.     exit 1
  121. fi
  122. ((hajs=$2-$1))
  123. if [ $hajs -lt 0 ]; then
  124.     echo "Za malo hajsu"
  125.     exit 1
  126. fi
  127. ((piatki=$hajs/5))
  128. ((hajs=$hajs-$piatki*5))
  129. for ((i=0;$i<$piatki;i++)); do
  130.     echo "5"
  131. done
  132. if [ $hajs -gt 0 ]; then
  133.     ((dwojki=$hajs/2))
  134.     ((hajs=$hajs-$dwojki*2))
  135.     for ((i=0;$i<$dwojki;i++)); do
  136.         echo "2"
  137.     done
  138.     if [ $hajs -gt 0 ]; then
  139.         echo "1"
  140.     fi
  141. fi
  142. 8:
  143. while read -r x; do
  144.     if [[ $x = *"/bin/bash"* ]]; then
  145.         echo $x
  146.     fi
  147. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top