Advertisement
Guest User

script3.sh

a guest
Nov 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo 'Enter a number: '
  4. read num1
  5. echo 'Enter in a bigger number: '
  6. read num2
  7.  
  8. if [ $num1 -gt $num2 ]
  9. then
  10.     echo "ERROR"
  11.     exit 2
  12. else
  13.     echo "The ordinary files in the directory $1 that are between $num1 bytes and $num2 bytes in size are the following:"
  14.     echo
  15.     for f in `ls $1`
  16.     do
  17.         if [ -f $f ] ; then
  18.             size=$(wc -c "$f" | cut -f 1 -d ' ')
  19.             if [[ $size -ge $num1 ]] && [[ $size -le $num2 ]] ; then
  20.                 echo "$f is $size bytes"
  21.             fi
  22.         fi
  23.     done
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement