Sorry for my bad english. I want to move a file from the Desktop to user's input destination. If destination has also a file with the same name, how can i ask user to rename the file so that he can have them both in destination folder? I have this right now:
#!bin/bash
echo "path"
read path
echo "Do you want to move code files somewhere else?"
read -t 5 y
if [[ $y = 'yes' ]] ; then
echo "Tell me where:"
read mydest
find $path -type f \( -name "*.c" -or -name "*.cxx" -or -name "*.cpp" -or -name "*.cc" \) );do
mv ???
fi
Demonstrating using mv
and switches -i
(interactive) and --backup
:
$ echo foo > foo # making test files
$ echo bar > bar
$ mv -i --backup foo bar # mving foo
mv: overwrite 'bar'? y # -i caused this
$ cat bar
foo # mv caused this
$ cat bar~ # --backup caused this
bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.