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"
}
Very effective, use only DNS protocol. The @ part is optional if you already set opendns servers as default ns servers.
This command uses nmap to perform reverse DNS lookups on a subnet. It produces a list of IP addresses with the corresponding PTR record for a given subnet. You can enter the subnet in CDIR notation (i.e. /24 for a Class C)). You could add "--dns-servers x.x.x.x" after the "-sL" if you need the lookups to be performed on a specific DNS server.
On some installations nmap needs sudo I believe. Also I hope awk is standard on most distros.
Use this BASH trick to create a variable containing the TAB character and pass it as the argument to sort, join, cut and other commands which don't understand the \t notation.
$ sort -t $'\t' ...
$ join -t $'\t' ...
$ cut -d $'\t' ...
Using perl and tput, show all the colors with numbers that your actual $TERM can handle.
If want to remove the numbers at beginning of new line, it should be something like this:
$perl -E 'say `tput setb $_`," "x `tput cols`, `tput sgr0` for 0 .. (`tput colors` - 1)'
When I go to change a configuration file I always like to make a backup first. You can use "cp -p" to preserve the modification time, but it gets confusing to have file.prev, file.prev2, etc. So I like to add a YYMMDD suffix that shows when the file was last changed.
"stat -c %Y" gives you the modification time in epoch seconds, then "date -d @" converts that to whatever format you specify in your "+format" string.
Mplayer starts a webcam capture using ASCII art. Only mplayer required
You need to install "sshpass" for this to work.
apt-get install sshpass