Commands by dbrgn (1)

  • This lists the number of ogg/mp3/wav/flac files in each subdirectory of the current directory. The output can be sorted by piping it into "sort -n". Show Sample Output


    0
    find . -type d -maxdepth 1 -print0 | xargs -0 -I{} sh -c 'find "{}" -type f | grep "ogg\|mp3\|wav\|flac$" | wc -l | tr -d "\n"; echo " {}"'
    dbrgn · 2013-12-22 13:40:29 0

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


Check These Out

Print out your hard drive to a jet-direct compatible printer.
Where 192.168.1.2 is a printer with jet-direct. No, I don't suggest this as a backup method.

Open Perl module source in your editor
Ever needed to look at the Perl source of an installed module on your system? This works in 90% of cases.

Search files with js declarations inside
Useful to crawl where the javascript is declared, and extract it a common file. You can redirect it to a file to review item by item.

Add your public SSH key to a server in one command
Just run the command, type your password, and that's the last time you need to enter your password for that server. This assumes that the server supports publickey authentication. Also, the permissions on your home dir are 755, and the permissions on your .ssh dir are 700 (local and remote).

Grep without having it show its own process in the results
The trick here is to use the brackets [ ] around any one of the characters of the grep string. This uses the fact that [?] is a character class of one letter and will be removed when parsed by the shell. This is useful when you want to parse the output of grep or use the return value in an if-statement without having its own process causing it to erroneously return TRUE.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Trim png files in a folder
That should be a short as it can get.

list files recursively by size

remove the last of all html files in a directory
sed can be used deleting the last line and with -i option, there's no need to for temp files, the change is made on the actual file

Make vim open in tabs by default (save to .profile)
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.


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: