Commands by s123iva (1)

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

Realtime lines per second in a log file
Using tail to follow and standard perl to count and print the lps when lines are written to the logfile.

Suppress output of loud commands you don't want to hear from

send raw data (hex written)using UDP to an IP and port
Use it to send raw data to a networked device. Used to interact with relay controller board whose documentation is lost, so use wireshark to sniff the sent data and replayed using the command.

Count the number of queries to a MySQL server

Drop all tables from a database, without deleting it
Uses two comands, requieres mysqldump, but works as expected.

Delete all non-printing characters from a file
tr has some predefined sets of characters that are more convenient to use than characters codes

Output a list of svn repository entities to xml file
I use this to pull the last commit date for everything in my repo, so I can tell the client which files haven't been touched or updated since the repo was created. Another way to do it is to use svn log, but that does not pull the "kind" attribute. It does, however, give you the commit message. Both are very useful.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

List alive hosts in specific subnet
Works on any machine with nmap installed. Previous version does not work on machines without "seq". Also works on subnets of any size.

quickest (i blv) way to get the current program name minus the path (BASH)
Useful in shell scripts when you're trying to get the shell script name without the full path - and easier than awking or cutting. Bash pattern matching and variable manip is fun.


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: