Some usefull commands to handle files

  1. Making a directory: mkdir command. mkdir takes one or more filenames as options. Enter info mkdir or mkdir --help for more information.

  2. Removing a directory: rmdir command. rmdir also takes one or more filenames as arguments. The directory must be empty before you can remove it.

  3. Copying files:

    cp sourcefile destinationfile

    The -r (recursive) option is useful when copying directory content.

  4. Renaming and moving files: mv command, e.g. mv file anotherfile. Both filenames may be either plain names, relative or absolute pathnames, just like the cp command uses.

  5. Removing files: rmfile. Note that the -f option (force), e.g. for removing directories that are not empty, is very powerful, but be absolutely sure when you use it: there's no trashcan or recycle bin in the Unix command line, so when a file is gone, it is really gone.

    Note

    The cp, mv and rm can be used interactively with the -i option. Since it offers a second chance to think about what you are about to do, aliassing these commands to their interactive counterparts may be a good thing for beginning users.

  6. Comparing files: use the diff file1 file2 command. The diff command has about 40 options, read at least the help info (--help option).

    Some systems offer ediff, a "diff to English" translator. The example below demonstrates that this might be a useful tool when comparing real life files:


tille:~>diff test1 test2 
1,3c1,4
< This is some text from file1.
< This is some more text from file1.
< This is the same text in each file. 
---
> This is some text from file2.
> This is some more text from file2.
> This is the same text in each file.
> This is text that only occurs in file2. 

Read at least the built-in short help for these commands.