Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. jpg=""
  2. count=`ls -1 *.jpg 2>/dev/null | wc -l`
  3. if [ $count != 0 ]
  4. then
  5. echo jpg files found: $count ; jpg="yes"
  6. fi
  7.  
  8. #!/bin/bash
  9.  
  10. shopt -s nullglob
  11.  
  12. for ext in jpg png gif; do
  13. files=( *."$ext" )
  14. printf 'number of %s files: %dn' "$ext" "${#files[@]}"
  15.  
  16. # now we can loop over all the files having the current extension
  17. for f in "${files[@]}"; do
  18. # anything else you like with these files
  19. done
  20.  
  21. done
  22.  
  23. ls | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}'
  24.  
  25. exts=( *.jpg *.png *.gif ); printf "There are ${#exts[@]}" extensions;
  26.  
  27. extensions="jpg png gif"
  28. for ext in $extensions; do
  29. c=$(find . -maxdepth 1 -iname "*.$ext" -print0 | tr -d -c "00" | wc -c)
  30. if [ $c -gt 0 ]; then
  31. echo "Found $c *.$ext files"
  32.  
  33. find . -maxdepth 1 -iname "*.$ext" -print0 | xargs -0 -r -n1 DOSOMETHINGHERE
  34. # or # find . -maxdepth 1 -iname "*.$ext" -exec "ls" "-l" "{}" ";"
  35. fi
  36. done
  37.  
  38. find -type f | sed -e 's/.*.//' | sort | uniq -c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement