Remove a symbolic link

unlink <linkname>
if you had a symbolic link called "oldLink" in the current folder then you would want to do unlink oldLink

-4
By: topgun553
2009-03-12 01:52:24

These Might Interest You

  • == remove broken links == find -L . -type l -exec rm -rf {} \; == how this work == "symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken. If you want to search for symbolic links when -L is in effect, use -xtype." -- manpage of find.


    8
    find -L . -type l
    jianingy · 2010-07-23 06:32:41 3
  • Replace '/tmp/file 1.txt' '/tmp/file 2.jpg' with "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" for Nautilus script Or with %F for Thunar action If you linking the symlinks itself, but want to link to source files instead of symlinks, use "`readlink -m "$i"`" instead of "$i" like this: for i in '/tmp/file 1.txt' '/tmp/file 2.jpg'; do ln -s "`readlink -m "$i"`" "$i LINK"; done ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Show Sample Output


    0
    for i in '/tmp/file 1.txt' '/tmp/file 2.jpg'; do ln -s "$i" "$i LINK"; done
    qwertyroot · 2013-08-02 08:30:50 0
  • if you wanted to create a new folder called "red" that was a symbolic link from /home/music/ to /home/hobbies/art then you would type: ln -s /home/hobbies/art /home/music/red


    -3
    ln -s /destinationTarget /sourceTarget/newFolder
    topgun553 · 2009-03-12 01:56:34 0
  • Extremely useful to maintain backups if you're using Dropbox. This mirrors the entire directory structure and places symlinks in each to the original file. Instead of copying over the data again to the ~/Dropbox folder creating a symbolic link tree is much more sensible in terms of space usage. This has to be supplemented by another script that removes dead symlinks in the Dropbox folder which point to files that have been moved/removed. 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.. ;)


    0
    find /home/user/doc/ -type d -printf "mkdir -vp '/home/user/Dropbox%p'\n" -o -type f -printf "ln -vs '%p' '/home/user/Dropbox%p'\n" | sh
    jnash · 2009-03-29 09:25:12 5

What Others Think

What's wrong with using "rm"?
flatcap · 484 weeks and 3 days ago
You kidding? Have you seen how huge and bloated rm is getting lately? I mean 50k, geez... Seriously though, there's no difference in what they fundamentally do aside from unlink not working on directories; unlink works just as well on regular files as it does on links.
TheMightyBuzzard · 484 weeks and 3 days ago
unlink has nothing to do with symbolic links. Note on some systems unlink() *can* unlink directories, with the tree underneath not being reaped until the next fsck.
pixelbeat · 484 weeks and 3 days ago

What do you think?

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.

What's this?

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.

Share Your Commands



Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: