0
0
Linux CLIscripting~15 mins

mv (move and rename) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Move and Rename Files with mv Command
📖 Scenario: You are organizing files in your home directory. You want to move a file from one folder to another and rename it at the same time.
🎯 Goal: Learn how to use the mv command to move and rename files in Linux.
📋 What You'll Learn
Create a file named exactly report.txt in the Documents folder
Create a variable called destination with the path to the Archives folder
Use the mv command to move report.txt from Documents to Archives and rename it to report_2024.txt
Print the command output or a confirmation message
💡 Why This Matters
🌍 Real World
Organizing files by moving and renaming them is a common task to keep your computer tidy and easy to navigate.
💼 Career
Knowing how to use the <code>mv</code> command is essential for system administrators, developers, and anyone working with Linux or Unix systems.
Progress0 / 4 steps
1
Create the initial file
Create an empty file called report.txt inside the Documents directory using the touch command.
Linux CLI
Need a hint?

Use touch Documents/report.txt to create an empty file named report.txt inside the Documents folder.

2
Set the destination folder path
Create a variable called destination and set it to the path Archives.
Linux CLI
Need a hint?

Set destination=Archives to store the folder path in a variable.

3
Move and rename the file
Use the mv command to move report.txt from the Documents folder to the folder stored in destination and rename it to report_2024.txt.
Linux CLI
Need a hint?

Use mv Documents/report.txt $destination/report_2024.txt to move and rename the file.

4
Confirm the move
Print a confirmation message that says exactly File moved and renamed successfully.
Linux CLI
Need a hint?

Use echo "File moved and renamed successfully" to show the message.