Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ ! $# -eq 2 ]; then
- echo "USAGE:"
- echo "Lab7_2.sh arg1 arg2"
- echo "arg1 is the from directory"
- echo "arg2 is the TO directory"
- elif [ ! -d $1 ]; then
- echo "The directory $1 is not valid!"
- else
- if [ ! -d $2 ]; then
- mkdir $2
- fi
- before=$PWD
- cd $1
- ls -l | cat > temp.txt
- FILES_TO_MOVE=$(sed -n '/^-rwx/p' temp.txt)
- echo "$FILES_TO_MOVE" | cat > temp.txt
- final=$(awk '{print $10 ;}' temp.txt)
- for file in $final
- do
- cp "$file" $before/$2/
- done
- rm temp.txt
- cd ..
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement