Advertisement
Guest User

Untitled

a guest
May 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.49 KB | None | 0 0
  1. #!/bin/bash
  2. if [ ! $# -eq 2 ]; then
  3. echo "USAGE:"
  4. echo "Lab7_2.sh arg1 arg2"
  5. echo "arg1 is the from directory"
  6. echo "arg2 is the TO directory"
  7. elif [ ! -d $1 ]; then
  8. echo "The directory $1 is not valid!"
  9. else
  10. if [ ! -d $2 ]; then
  11. mkdir $2
  12. fi
  13. before=$PWD
  14. cd $1
  15. ls -l | cat > temp.txt
  16. FILES_TO_MOVE=$(sed -n '/^-rwx/p' temp.txt)
  17. echo "$FILES_TO_MOVE" | cat > temp.txt
  18. final=$(awk '{print $10 ;}' temp.txt)
  19. for file in $final
  20. do
  21. cp "$file" $before/$2/
  22. done
  23. rm temp.txt
  24. cd ..
  25. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement