I was cleaning up a directory of old files for addition to git, and I came across a bunch of symlinks to a completely different codebase. In this particular case it was a wordpress blog that had a series of its files linked into the webroot of the site, that existed in an entirely different directory. I didn't want these files in the git repo.

Finding all the symlink files is easy enough.

cd/path/to/root

The find command gives us an easy way to get all symlink files:

find . -type l

But that's just a start -- we have to get these into the .gitignore file.

./wp-blog-header.php
./wp-login.php

These are perfect for a cut and paste addition to the .gitignore or even just appending them to it, if not for the leading period. How could we remove that?

Well as it happens, we can pipe the output to cut. What if we cut the first character? Specifying cut -c n, will cut n characters.

While the trailing dash looks cryptic, it's really part of a range, as in the option N-M where N is the first character and M is the last character position. Leaving off the 'M" is just telling cut to give us "from N- to the last character in the line".

So the problem we have is that we want the 2nd character in the line, and then all the rest.