Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
en:handbook:commands [2012/06/02 16:21] naitsirhc fix broken wget example |
en:handbook:commands [2016/10/01 07:30] (current) hgt Examples are more fit to illustrate renaming than copying of file contents. |
||
|---|---|---|---|
| Line 61: | Line 61: | ||
| ===== Move (rename) files or directories ===== | ===== Move (rename) files or directories ===== | ||
| - | The mv command takes the contents of a file and copies it to a new file, then deletes the original file: | + | When source and target file are in the same file system and the target file does not exist, the mv command simply renames the source file: |
| <code> $ mv file1 file2 </code> | <code> $ mv file1 file2 </code> | ||
| Line 72: | Line 72: | ||
| <code> $ mv file1 file2 dir1 dir2 ~/Documents </code> | <code> $ mv file1 file2 dir1 dir2 ~/Documents </code> | ||
| + | |||
| + | When renaming is not possible, the mv command takes the contents of a file and copies it to a new file, then deletes the original file. | ||
| ===== Create a new file ===== | ===== Create a new file ===== | ||
| Line 102: | Line 104: | ||
| <code> $ rm -rf /home/hacker/Templates </code> | <code> $ rm -rf /home/hacker/Templates </code> | ||
| + | |||
| + | <note important>Be careful when using this option. It will delete everything without asking!</note> | ||
| Note you can also use the //-i// option to remove files or directories and their contents interactively: | Note you can also use the //-i// option to remove files or directories and their contents interactively: | ||