Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. #del
  3.  
  4. #check arguments
  5. if [ "$1" == "" ]; then
  6.     echo "No file given"
  7.     exit 1
  8. fi
  9.  
  10. #check dustbin
  11. if [ ! -d /root/my-applications/bin/dustbin ]; then
  12.     mkdir /root/my-applications/bin/dustbin
  13. fi
  14.  
  15.  
  16. for file in $@;
  17. do
  18.     #file name
  19.     name=`basename "$file"`
  20.     #dir name
  21.     destination=`dirname "$file"`
  22.     if [ ! -d $destination ]; then
  23.         pwd=`pwd`
  24.         touch /root/my-applications/bin/dustbin/path$name && echo >> "$pwd"
  25.     else
  26.         touch /root/my-applications/bin/dustbin/path$name
  27.         echo $destination >> /root/my-applications/bin/dustbin/path$name
  28.     fi
  29.     if [ -f $file ]; then
  30.         mv $file /root/my-applications/bin/dustbin
  31.         echo "File $file deleted"
  32.     else
  33.         echo "File $file does not exist"
  34.     fi
  35. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement