What is the syntax for using the `mv` command to rename files?

The syntax for using the mv command to rename files is as follows:

mv [options] old_filename new_filename

Example

To rename a file from oldname.txt to newname.txt, you would use:

mv oldname.txt newname.txt

Options

You can include options if needed:

  • -i: Prompt before overwriting an existing file.
  • -v: Provide verbose output to show the renaming process.

Example with Options

mv -iv oldname.txt newname.txt

This command will rename oldname.txt to newname.txt, prompting for confirmation if newname.txt already exists and showing the action taken.

0 Comments

no data
Be the first to share your comment!