Check These Out
retrieve file names back from touch commands for them
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"
}
Generate a truly random password using noise from your microphone to seed the RNG. This will spit out 12 password with 12 characters each, but you can save this into a bash script and replace 'pwgen -ys 12 12' with 'pwgen $@' so you can pass any paramters to pwgen as you would normally do.
Friday is the 5th day of the week, monday is the 1st.
Output may be affected by locale.
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}...