Guest User

Untitled

a guest
Jan 24th, 2018
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # fns
  4.  
  5. if [ -z "$1" ]; then
  6. echo 'Usage: fns string1 string2 ... [-v stringA stringB ...]'
  7. echo
  8. echo 'Finds files under CWD whose pathname contains all of the strings 1, 2, etc,'
  9. echo 'and none of the (optional) strings A, B, etc. Case insensitive.'
  10. exit
  11. fi
  12.  
  13. function printfct
  14. {
  15. while read fqname; do
  16. size=$(stat -c %s "$fqname")
  17. size2="$(printf "%'13d" $size)"
  18. echo "$size2" $fqname
  19. done
  20. }
  21.  
  22. cmd="find -L . -print | grep -i $1"
  23. vflag=false
  24.  
  25. while [ -n "$2" ]; do
  26. if [ "$2" = "-v" ]; then
  27. vflag=true
  28. else
  29. if $vflag; then
  30. cmd=$cmd" | grep -iv $2"
  31. else
  32. cmd=$cmd" | grep -i $2"
  33. fi
  34. fi
  35. shift
  36. done
  37.  
  38. eval $cmd | sort | printfct |o
  39.  
  40. exit
Add Comment
Please, Sign In to add comment