To rename a file while copying it to another directory, you can specify the new name in the destination path.
Syntax:
cp source_file destination_directory/new_file_name
Example:
If you want to copy file.txt to the backup directory and rename it to file_backup.txt, you would use:
cp file.txt backup/file_backup.txt
This command copies file.txt into the backup directory and renames it to file_backup.txt. If you have any further questions, feel free to ask!
