I was tired of the endless quoting, unquoting, re-quoting, and escaping characters that left me with working, but barely comprehensible shell one-liners. It can be really frustrating, especially if the local and remote shells differ and have their own escaping and quoting rules. I decided to try a different approach and ended up with this.
The host command comes with the bind-utils package, which is has a better chance to be installed than resolveip from mysql. The last word of the query result is displayed, which is the last result host got. This works with CNAMEs. You get "3(NXDOMAIN)" in case of failure. Show Sample Output
Execute commands serially on a list of hosts. Each ssh connection is made in the background so that if, after five seconds, it hasn't closed, it will be killed and the script will go on to the next system. Maybe there's an easier way to set a timeout in the ssh options...
Cleaned up and silent with &>/dev/null at the end. Show Sample Output
Gives the DNS listed IP for the host you're on... or replace `hostname` with any other host Show Sample Output
alternative using 'host' Show Sample Output
Get just the IP address for a given hostname. For best results, make this a function in your shell rc file so that it can be used for things like traceroute: Titus:~$ traceroute `getip foo.com` traceroute to 64.94.125.138 (64.94.125.138), 64 hops max, 52 byte packets Show Sample Output
This is a better way to do the "src X or dst X" filter; plus you might not want to bother with DNS lookups (-n).
This is a useful command that gives the hostname and the IP Address of your machine, on many OS. Tested on Linux and Solaris. host command here is followed by `hostname`. Note the ` in the command is a back quote (or grave accent or back tic that usually shares the space with the ~ key). No other options are specified. See sample output. Show Sample Output
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.
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
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: