The mv command in Unix is like a versatile tool for moving or renaming files and directories.
It stands for “move” and does exactly that—it moves files or directories from one location to another or renames them. When you type mv
followed by the source file or directory and the destination, it performs the specified action.
mv
Moves or renames files and directories.
mv [source] [destination]
ls command is used for show list of available folders and files in current directory, so there we have already created bhai4you.txt file for better understanding.
we want to move bhai4you.txt file to storage folder so how can i do that ? that’s why we used mv command for move file to one destination to another so just paste below command in termux.
mv bhai4you.txt storage
you can see bhai4you.txt moved successfully because now it is not visible in current $HOME directory. lets see storage folder
you can see in above screenshot bhai4you.txt file is in storage folder. you can use cd command to change directory to storage then enter ls command for show available files and folders in storage directory.
what if destination folder is not in current directory ? then you need to add path of destination folder follow below method if you want to move your file to another location using folder path.
mv [source] [destination]
Moves the file or directory from the specified source location to the specified destination location. It can also be used to rename files or directories by specifying a different name for the destination.
mv bhai4you.txt /data/data/com.termux/files/home/
i hope now you are familiar with ls and cd command so i am not explaining again just we have moved our bhai4you.txt file from location storage to $HOME (/data/data/com.termux/files/home) using directory path instead of using folder name.
mv –help
This command shows all available options for the mv command. It can be useful for exploring additional functionalities beyond simple moving and renaming.
mv --help
The mv command is essential for managing files and directories in Unix systems, allowing you to easily rearrange or rename them to organize your file system efficiently.