The mv
command is used to move a file from one location in the filesystem to another.mv
SOURCE DESTINATION
The mv
command requires at least two arguments. The first argument is the source, a path to the file to be moved. The second argument is the destination, a path to where the file will be moved to. The files to be moved are sometimes referred to as the source, and the place where the files are to be placed is called the destination.
To move the people.csv file into the Work directory, use the filename as the source, and the directory name as the destination. If a file is moved from one directory to another without specifying a new name for the file, it will retain its original name. The move above can be confirmed using the ls
command on the Work directory:
Moving a file within the same directory is an effective way to rename it. For example, in the following example the animals.txt file is given a new name of zoo.txt:
Note: Permissions can have an impact on file management commands, such as the mv command. Moving a file requires write and execute permissions on both the origin and destination directories.