kaushal_07 kaushal_07 - 8 days ago 6
Bash Question

shell script to simulate the mv command in linux

I am a beginner in shell script and have to code a script to simulate the functionality of mv command of linux without actually using the mv command in my script. Please help me I will be very thankful !

Answer

If you want to simulate the mv command you need to copy the file that you want to "move" to the destination folder then you have to delete the old one.

Here is a little script:

#!/bin/bash from=$1 to=$2 echo "Copy from $1 to $2" cp $1 $2 echo "Removing the old file $1" rm $1 echo "Done."


Hope that will help you