3rd November, 2009

What order do filenames go in *NIX?

I find it's easiest to remember the order of filename parameters with the following rule:

The first file must exist, the second file doesn't HAVE to.

It's left to right - the way we write. This rule works pretty much everywhere. For example:

nano test.txt

If test.txt exists it is opened, if it doesn't exist, it is created.

cp filename1 filename2

Which direction do they get copied? filename1 must exist more than filename2 therefore filename2 is the new file.

ln -s my_file another_file

If the left file must exist then we are creating a symlink called another_file --> my_file.

This is only a general rule of thumb and not all applications are created equal, but it should make it easier to remember parameter orders.


The opinions expressed here are my own and not those of my employer.