Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.87 KB | None | 0 0
  1. #!/bin/bash
  2. if [ $# -eq 0 ]
  3. then
  4.     echo "Podales za malo argumentow!"
  5. elif [ $# -ge 3 ]
  6. then
  7.     echo "Podales za duzo argumentow!"
  8. else
  9.     flag=false
  10.     if [ $# -eq 1 ]
  11.     then
  12.         if [ $1 = newest ] || [ $1 = oldest ]
  13.         then
  14.             sort=$1
  15.             src=$pwd
  16.             flag=true
  17.         else
  18.             sort=newest
  19.             src=$1
  20.             if [[ $src == /* ]]
  21.             then
  22.                 flag=true
  23.             fi
  24.         fi
  25.     else
  26.         sort=$2
  27.         src=$1
  28.         if [[ $src == /* ]]
  29.         then
  30.             flag=true
  31.         fi
  32.     fi
  33. if $flag
  34. then
  35.     od $src
  36.     if [ $sort = newest ]
  37.     then
  38.         ile=$(echo `ls -t | wc -l`)
  39.         let liczba=($ile*10)/100
  40.         if [ $liczba -eq 0 ]
  41.         then
  42.             liczba=1
  43.         fi
  44.         echo `ls -t | head -$liczba`
  45.     elif [$sort = oldest ]
  46.     then
  47.         ile =$(echo `ls -tr | wc -l`)
  48.         let liczba=($ile*10)/100
  49.         if [ $liczba -eq 0]
  50.         then
  51.             liczba=1
  52.         fi
  53.         echo `ls -tr | head -$liczba`
  54.     fi
  55.     else
  56.         echo "Podany argument nie jest scicezka!"
  57.     fi
  58. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement