Show most common words in filenames

ls | tr '[[:punct:][:space:]]' '\n' | grep -v "^\s*$" | sort | uniq -c | sort -bn
I'm sure there's a more elegant sed version for the tr + grep section.

3
By: qdrizh
2014-10-14 09:52:28

These Might Interest You

  • All words of the filenames except "a", "of", "that" and "to" are capitalized. To also match words which begin with a specific string, you can use this: rename 's/\b((?!hello\b|t)[a-z]+)/\u$1/g' * This will capitalize all words except "hello" and words beginning with "t".


    3
    rename 's/\b((?!(a|of|that|to)\b)[a-z]+)/\u$1/g' *
    John_W · 2010-08-22 15:00:33 0
  • The improvement of this command over Strawp's original alternative is that you can specify the size of the words, in this particular case words between 3 and 5 character's long. It also excludes words that contain apostrophes, if you'd rather keep those words simply substitue [^'] for . Show Sample Output


    2
    echo $(grep "^[^']\{3,5\}$" /usr/share/dict/words|shuf -n4)
    j_melis · 2011-08-23 21:15:18 3
  • Quick and dirty command that counts how many words can be typed just using the home row on the Dvorak Simplified Keyboard layout from a dictionary file, in this case /usr/share/dict/words. According to the regular expression supplied, each word must contain all the keys on the Dvorak home row, and no other characters. For comparison, I've shown how many words are installed in my dictionary, how many can be typed with just the Dvorak home row and how many can be typed with just the QWERTY home row in the sample output. Nearly 10 times the amount. If you want to see the words, remove the -c switch, and each word will be printed out. Show Sample Output


    5
    egrep -ci ^[aoeuidhtns-]+$ /usr/share/dict/words
    atoponce · 2009-04-15 20:31:46 3
  • ls -Q will show the filenames in quotes. xargs -p rm will print all the filenames piped from ls -Q and ask for confirmation before deleting the files. without the -Q switch, if we have spaces in names, then the files won't be deleted. Show Sample Output


    1
    ls -Q * | xargs -p rm
    temp_reg · 2010-01-27 02:46:49 6

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: