Write a Bash script called move that could replace the UNIXcommand mv. ‘move’ tries to rename the source file (using the UNIXcommand mv), but if the destination file exists, appends an indexnumber, a sort of version number, to the destination file. So ifthe 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 namethat does not already exist.
Solution
BashScript:
#!/bin/bash
# Fetching file name from arguments
SFile=”$1″
DFile=”$2″
name=$DFile
serial=1
while [ 1 ]
do
# Checking for existence of file
OR
OR