To rename a file while copying in Unix-like operating systems, you can specify the new name in the destination path.
Command Syntax:
cp source_file new_directory/new_file_name
Example:
If you want to copy file2.txt to testdir and rename it to newfile.txt, you would use:
cp file2.txt testdir/newfile.txt
This command copies file2.txt into testdir and renames it to newfile.txt.
If you have more questions or need further clarification, feel free to ask!
