shell - Trying to move a file to another directory with the inode number attached -


so have slight issue code. trying move file users wants in deleted directory. situation file needs have inode attached within deleted directory in form $filename_$inode. instance, in home directory have file named good.txt. want move deleted directory , file should in format of good.txt_12234. should do? tried using brace expressions here reason keep getting errors. i've attached part of code below. once solve issue, rest of code work. everyone!

   echo "safe_rm cannot remove '$1' : directory"  38       exit 1  39       fi  40   }  41 error_checking $1  42  43 ## test 3 error conditions based on file given.  44  45 ##5.  46  47 file_inode(){  48  49 filename="$1"  50 inode=$(ls -i "$1"| cut -d" " -f1)  51 mv $1 $home/deleted  52 }  53  54 file_inode $1 

update: able kind of figure out problem. did following: mv $1 $home/deleted/$1_$inode. file able move deleted directory. however, when try .restore.info, keeps showing message ls: cannot find "$1"- no such file or directory? did wrong on part? i'll attach code better analysis. thank again everyone.

 error_checking(){  25  26 filename=$1  27   if [ ! -e "$1" ] ;  28        29       echo "safe_rm :cannot remove '$1' : no such file or directory"  30     exit 1 #will stop script if there no file or directory  31   elif [ $# -eq 0 ] ;  32        33       echo "safe_rm : missing operand"  34       exit 1  35   elif [ -d "$1" ] ;  36      37       echo "safe_rm cannot remove '$1' : directory"  38       exit 1  39       fi  40   }  41 error_checking $1  42  43 ## test 3 error conditions based on file given.  44  45 ##5.  46  47 file_inode(){  48  49 filename="$1" 50 inode=$(ls -i "$1"| cut -d" " -f1)  51 mv "$1" $home/deleted/$1_$inode  52 }  53  54 file_inode $1  55  56 ##this move file recycle bin , format filena    me_inode.  57  58 ##6  59  60 movefile(){  61  62 filename=$1  63 inode=$(ls -i $1| cut -d" " -f1)  64 touch $home/.restore.info  65 readlink=$home/deleted/$1_$inode  66 path=$(readlink -m $1)  67 echo "$1_$inode:$path">> $home/.restore.info 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -