linux - Bash renaming from path variable -


i'm doing "recycle bin" type script, have done if file exists try restore file want let user choose new name file restored as, have full path file deleted in variable $f1 dont know how go changing file name here

#!/bin/bash  trashcan ="/home/alihassan/desktop/trashcan" cd $trashcan f1=$( grep "$1" storage.txt ) if [ -f $f1 ]     echo "file exists @ restore location, please enter new filename"     read ans     mv "home/alihassan/desktop/trashcan/$1" "$f1/$    #issue here else     mv "/home/alihassan/desktop/trashcan/$1" "$f1" fi 

on face of it, might after:

mv "$trashcan/$1" $(dirname "$f1")/"$ans" 

this preserves original path $f1 except last component, , uses answer in place of last component.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -