[Bash] mv command
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
use with {}
For example I want to override and rename file.txt_
with file.txt
mv file.txt{_,}
You can also check the full command with echo
echo mv file.txt{_,}
# > mv file.txt_ file.txt