What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands tagged links from sorted by
Terminal - Commands tagged links - 7 results
find . -type f -a \! -links 1
2013-05-06 20:44:08
User: malathion
Functions: find
Tags: find links

libpurple likes to hardlink files repeatedly. To ignore libpurple, use sed: | sed '/\.\/\.purple/d'

for FILE in `ls -1`; do if [ -L "$FILE" ]; then cp $(readlink "$FILE") ${FILE}_rf; rm -f $FILE; mv ${FILE}_rf "$FILE"; fi; done
(IFS=$'\n'; ln -sf $(awk '((NR % 2) != 0 && NR > 1) {print "prefix" $0}' list.m3u) target_folder)
2011-09-25 16:45:28
User: lxe
Functions: awk ln

This command will place symbolic links to files listed in an m3u playlist into a specified folder. Useful for uploading playlists to Google Music.

prefix = The full path prefix to file entries in your .m3u file, if the file paths are relative. For example, if you have "Music/folder/song.mp3" in your list.m3u, you might want to specify "/home/username" as your prefix.

list.m3u = Path to the playlist

target_folder = Path to the target folder in which you would like to create symlinks

links -dump "http://spaceflight.nasa.gov/realdata/sightings/cities/view.cgi?country=United_States&region=Wisconsin&city=Portage" | sed -n '/--/,/--/p'
2011-05-03 12:15:56
User: eightmillion
Functions: sed
Tags: sed links iss

This command outputs a table of sighting opportunities for the International Space Station. Find the URL for your city here: http://spaceflight.nasa.gov/realdata/sightings/

find -L / -samefile /path/to/file -exec ls -ld {} +
2011-04-27 06:14:15
User: eightmillion
Functions: find ls

This command finds and prints all the symbolic and hard links to a file. Note that the file argument itself be a link and it will find the original file as well.

You can also do this with the inode number for a file or directory by first using stat or ls or some other tool to get the number like so:

stat -Lc %i file


ls -Hid file

And then using:

find -L / -inum INODE_NUMBER -exec ls -ld {} +
find /deep/tree/ -type f -print0|xargs -0 -n1 -I{} ln -s '{}' .
2010-12-21 13:00:33
User: dinomite
Functions: find ln xargs
Tags: find xargs links

If you want to pull all of the files from a tree that has mixed files and directories containing files, this will link them all into a single directory. Beware of filesystem files-per-directory limits.

symlinks -r $(pwd)
2009-05-01 23:33:10
User: kFiddle
Tags: symlinks links

The symlinks command can show status of all symbolic links, including which links are dangling, which symlinks point to files on other file systems, which symlinks use ../ more than necessary, which symlinks are messy (e.g. having too many slashes or dots), etc. Other useful things it can do include removing all dangling links (-d) and converting absolute links to relative links (-c). The path given must be an absolute path (which is why I used $(pwd) in the example command).