Check These Out
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"
}
$ translate [output-language] [source-language]
1) "some phrase" should be in quotes
2) [output-language] - optional (default: English)
3) [source-language] - optional (default: auto)
$ translate "bonjour petit lapin"
hello little rabbit
$ translate "bonjour petit lapin" en
hello little rabbit
$ translate "bonjour petit lapin" en fr
hello little rabbit
Friday is the 5th day of the week, monday is the 1st.
Output may be affected by locale.
This says if the LHC has destroyed the world. Run it in a loop to monitor the state of Earth. Might not work reliable, if the world has actually been destroyed.
Lots of scripts show you how to use socat to send an email to an SMTP server; this command actually emulates an SMTP server!
It assumes the client is only sending to one recipient, and it's not at all smart, but it'll capture the email into a log file and the client will stop retrying.
I used this to diagnose what emails were being sent by cron and subsequently discarded, but you can use it for all sorts of things.
For Linux distributions using rpm (eg Mandriva), this command will find the rpm package name that provides a file.
Several times, I find myself hitting my up arrow, and changing the search term. Unfortunately, I find myself wasting too much time typing:
$ grep kernel /var/log/messages
Redirecting STDIN allows me to put the search term at the end so I less cursor movement to change what I'm searching for:
$ < /var/log/messages grep kernel
If you're using the emacs keyboard binding, then after you press your up arrow, press CTRL+w to erase the word.
If this has already been submitted, I couldn't find it with the search utility.
Will automatically take the size of the file but longer, usefull only if in an function.
GeoIP Needs to be installed. Can be done from some distro's or via MaxMind.com for free. There even is a free city database availabble. If the GeoLiteCity is downloaded and installed it will also find more information
$ geoiplookup -f /var/lib/GeoIP/GeoLiteCity.dat commandlinefu.com
GeoIP City Edition, Rev 1: US, NJ, Absecon, 08201, 39.420898, -74.497704, 504, 609
A simple directive which disables all aliases and functions for the command immediately following it. Shortcut for the bash built-in 'command' - "command linefoo".
Think, {sic}...