Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. file=./tmp
  4. fileThreshold=10
  5.  
  6. if [ ! -e "$file" ]; then
  7. echo "No such directory exists, directory has just been created"
  8. mkdir $file
  9. else
  10. echo "Directory exists"
  11. fi
  12.  
  13. echo "Changing directory to $file"
  14. cd $file
  15.  
  16. fileCount=`ls -l . | egrep -c '^-'`
  17. echo "$fileCount files found within $file"
  18.  
  19. if [ "$fileCount" -gt "$fileThreshold" ]; then
  20. cd ../
  21. echo "changing directory to parent of $file"
  22. tar -zcvf files.tar.gz $file
  23. echo "Create ${file} archive"
  24. cd $file
  25. rm -rf *
  26. cd ../
  27. echo "Files collected"
  28. else
  29. echo "Not enough files to require archive"
  30. fi
  31.  
  32. echo "Done."
  33. exit 1
  34.  
  35. loopCounter=0
  36. while [ "$loopCounter" -lt "11" ]; do
  37. loopCounter=$((loopCounter + 1))
  38. fileName=`date +%s`
  39. touch $fileName
  40. echo $fileName
  41. sleep 1
  42. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement