find -L ./ -type l -delete
And then removing empty directories
find ./ -type d -exec rmdir 2>/dev/null {} \;
**Actually after some finding I found lndir which creates symbolic trees but it wasn't in the Arch repos so.. ;)
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
cp -al src dest
Rather than dangling symlinks, which can also be found using the "symlinks" command, you will end up with files with a hard-link count of 1.find src -type f -links 1 -delete
Finally you can tidy the empty directory command:find . -depth -type d ! -name . -exec rmdir --ignore-fail-on-non-empty {} \;
This version will remove deep, but empty trees, and it won't complain about non-empty dirs.echo foo>file;ln -s file symlink;cat file;echo whoops>file;cat symlink
This creates a file, symlinks it, edits the file, and changed your "backup". Hard links aren't safe either. do the same thing, only, you have to look harder to find out it's a link.echo foo>file;ln file hardlink;cat file;echo whoops>file;cat hardlink
The only way to back up the data is to actually copy it elsewhere. If you want to back up and save space, then rsync is your friend. It has some parameters that will compare to previous backups, and copy any changed files since the last backup, and hard link the rest. This way, you can delete any backup you want, and all others are unaffected. I can't tell you what they are, but google will help out: http://www.google.com/search?q=rsync+incremental+backup You may also be interested in Flyback, http://flyback-project.org/ , which is a gui wrapper over rsync. Good luck!