touch ~/Documents/myfile.txt
Usually, the touch command updates the modication and access date for an
existing le. If you use touch with a lename which does not exist in your
target directory, it creates a new le.
3 Enter
ls -l ~/Documents
The new le should appear in the list of contents.
4 To copy the newly created le, enter
cp ~/Documents/myfile.txt .
Do not forget the dot at the end.
This command tells Bash to go to your home directory and to copy myfile.txt
from the Documents subdirectory to the current directory, /tmp/test, without
changing the name of the le.
5 Check the result by entering
ls -l
The le myfile.txt should appear in the list of contents for /tmp/test.
Procedure 17.3: Renaming and Removing Files or Directories
Now suppose you want to rename myfile.txt into tuxfile.txt. Finally you decide
to remove the renamed le and the test subdirectory.
1 To rename the le, enter
mv myfile.txt tuxfile.txt
2 To check what happened, enter
ls -l
Instead of myfile.txt, tuxfile.txt should appear in the list of contents.
mv stands for move and is used with two options: the rst option species the
source, the second option species the target of the operation. You can use
mv either
• to rename a le or a directory,
• to move a le or directory to a new location or
• to do both in one step.
198 Start-Up