Detailed use of mv command under linux

  
                  Users can use the mv command to rename a file or directory or move a file from one directory to another. This command is like the combination of ren and move under MSDOS.

syntax: mv [options] source file or directory target file or directory

Description: Depending on the mv command in the second argument of a different type (the target file or target directory), mv command Rename the file or move it to a new directory. When the second parameter type is a file, the mv command completes the file renaming. At this time, the source file can only have one (or the source directory name), and it renames the given source file or directory to the given one. The name of the target file. When the second parameter is an existing directory name, there may be multiple source files or directory parameters. The mv command moves the source files specified by each parameter to the target directory. When moving a file across a file system, mv copies first, then the original file is deleted, and the link to the file is lost. The meaning of each option

command is:

- I interact operations. If the mv operation will result in an overwriting of the existing target file, the system asks whether to rewrite, and asks the user to answer y or n, so as to avoid accidentally overwriting the file.

- f prohibit interoperability. No indication is given when the mv operation wants to overwrite an existing target file. After this option is specified, the i option will no longer work.

if the target file (not a directory) to an existing, then the contents of the file will be overwritten by new files. To prevent users from using the mv command to destroy another file, it is best to use the i option when moving files using the mv command.

rm command

users can delete unnecessary files with the rm command. The function of this command is to delete one or more files or directories in a directory. It can also delete a directory and all files and subdirectories under it. For linked files, just the link is broken and the original file remains unchanged. The general form of

rm command is:

rm [options] files ...

If you do not use the - r option, rm will not remove directories.

the options of this command is as follows:

- f ignore nonexistent files, never prompt.

- r rm will indicate all the parameters listed in directories and subdirectories are recursively deleted.

- i interactive deleted.

to be careful with the rm command. Because once the file is deleted, it cannot be recovered. To prevent this from happening, you can use the i option to confirm the files you want to delete one by one. If the user enters y, the file will be deleted. If you enter anything else, the file will not be deleted.
Copyright © Windows knowledge All Rights Reserved