Advertisement
Tavi33

SO #2

Oct 4th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. if test $# -lt 2
  2. then
  3.   echo "Usage: $0 $f [arg1, arg2, ...]"
  4. else
  5.   file=$1
  6.   shift
  7.   ccount=0
  8.   pcount=0
  9.   for str
  10.   do
  11.     pathc=`echo $str | grep -c "^/"`
  12.     if test $pathc -gt 0
  13.     then
  14.       chars=`echo $str | wc -L`
  15.       ccount=`expr $chars + $ccount`
  16.       pcount=`expr $pcount + 1`
  17.     fi
  18.   done
  19.   if [ -f $file ]
  20.   then
  21.     echo "Paths: $pcount; Total character count: $ccount" > $file
  22.   else echo "File $file is not a regular file"
  23.   fi
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement