Advertisement
STANAANDREY

solab1pb5

Feb 24th, 2024 (edited)
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.33 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 2 ]; then
  4.     echo "Usage: $0 <dir> <outfile>"
  5.     exit 1
  6. fi
  7.  
  8. dir=$1
  9. ofile=$2
  10.  
  11. if [ ! -d $dir ]; then
  12.     echo "$dir isn't a dir"
  13.     exit 1
  14. fi
  15.  
  16. flist=$(find $dir -type f -name '*.txt')
  17.  
  18.  
  19. for file in $flist
  20. do
  21.     cnt=$(wc -c $file | awk '{print $1}')
  22.     echo "$file: $cnt" >> $ofile
  23. done
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement