commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
If we want files with more than one extension, like .tar.gz, only appear the latest, .gz:
ls -Xp /path/to/dir | grep -Eo "\.[^./]+$" | uniq
There are 2 alternatives - vote for the best!
... plus do a sort according frequency
Works on current directory, with built-in sorting.
Get the longest match of file extension (Ex. For 'foo.tar.gz', you get '.tar.gz' instead of '.gz')
Just a little simplification.
If your grep doesn't have an -o option, you can use sed instead.
If you can do better, submit your command here.
You must be signed in to comment.