Tuesday, December 24, 2013

Raspberry Pi Journal #42


Symbolic Linking

Here's something to ponder. Let's say that you want to have a certain file that is frequently modified. But, you also want to have a copy of all the modifications. Something like a running log. You can, of course, do it like this:


  1. Create the file, make changes to it, etc.
  2. Copy the file to some other name, adding timestamp.


So, let's say we have a file called Musings.txt. We can use this command copy the file, while adding time stamp.

cp Musings.txt `date Musings_%F.txt`

You can change the date format to anything you like. See the man pages for "date" for details.

Another way to have a file associated with changes, and this is important if you want to make changes to it, but want the file associated with the latest stable version, as opposed to the latest edited, is to use symbolic link command.

ln -s original_file linked_file

By making copy as a linked file, you can refer to the linked file whenever you want, and refer to the original file. Then when you're ready, simply replace the linked file to the updated one.


  1. rm linked_file
  2. ln -s updated_file linked_file


It's a two step process, but you can work with the updated file to your heart content, and be sure to have the updated file ready to be "released", without changing anything else.

It's similar to copy, but more space efficient.

No comments:

Post a Comment