Advertisement
phuongnx

C5_11

Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2. echo "nhap thu muc thu nhat: "
  3. read dir1
  4. echo "nhap thu muc thu 2: "
  5. read dir2
  6. if test ! -d $dir1
  7. then
  8.     echo "thu muc "$dir1" khong ton tai"
  9. fi
  10. if test ! -d $dir2
  11. then
  12.     echo "thu muc "$dir2" khong ton tai"
  13. fi
  14. if [ -d $dir1 ] && [ -d $dir2 ]
  15. then
  16.     ls -l $dir1 | awk '$1 != "total" {print $1,$9}' | while read output
  17.         do
  18.         array=($output)
  19.             if [ ${array[0]:0:1} == '-' ]
  20.             then
  21.                 if [ -f $dir2"/"${array[1]} ]
  22.                 then
  23.                     rm -f $dir1"/"${array[1]}
  24.                 fi
  25.             fi
  26.         done
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement