[Bash] mv command

Zhentiw發表於2024-05-14

mv

The mv command is used to rename and overwrite files and directories.

To rename a file, set the first argument to the original file name and the second argument to the new file name or the destination directory.

rename a file

# rename message.txt to msg.txt
mv message.txt msg.txt

overwrite a file content

# overwrite the content of target.txt with source.txt file content
# cat source.txt
# > soruce content
# cat target.txt
# > target content
mv source.txt target.txt

cat target.txt
# > source content

rename a directory

# rename directory cool to good
mv cool good

相關文章