Write a Bash script called move that could replace the UNIX command mv. \'move\'
ID: 3683856 • Letter: W
Question
Write a Bash script called move that could replace the UNIX command mv. 'move' tries to rename the source file (using the UNIX command mv), but if the destination file exists, appends an index number, a sort of version number, to the destination file. So if the user types:
move a.txt b.txt
and b.txt already exists, move will rename the file to b.txt.1. If b.txt.1 already exists, move must rename the file to be b.txt.2, and so on, until the file can be successfully renamed with a name that does not already exist.
Explanation / Answer
#!/bin/bash PATH="/var/opt/" #Rename before cd $PATH mv "a.txt" "file1.php.org" mv "b.txt" "file1.php" exit 0 fi
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.