Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. destination=("/e/library/notes/back" "/home/user" "/c/WINDOWS/bin")
  4. source="/home/user/mylog"
  5. prefix="mlog"
  6.  
  7.  
  8. function do_clear {
  9.         for a_path in ${destination[@]}; do
  10.                 find $a_path -iname "*$prefix*" -exec rm {} \;
  11.  
  12.         done
  13.         echo "cleaned..."
  14.         exit 0
  15. }
  16.  
  17.  
  18. if [ "$1" == "-c" ]; then do_clear; fi
  19.  
  20. function do_copy {
  21.         for a_path in "${destination[@]}"; do
  22.  
  23.                 cp $source "$a_path/$prefix`date +%Y%b%d`"
  24.                 if [  $? -ne  0  ]; then return 1; fi
  25.  
  26.         done
  27.         return 0
  28. }
  29.  
  30. do_copy
  31.  
  32. if [ $? -eq 0 ]; then echo "succeed..."; exit 0
  33. else echo "SOMETHING WRONG!"; exit 1;
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement