Check These Out
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video).
$ cat /proc/acpi/video/VGA/LCD/brightness
to discover the possible values for your display.
All words of the filenames except "a", "of", "that" and "to" are capitalized.
To also match words which begin with a specific string, you can use this:
$ rename 's/\b((?!hello\b|t)[a-z]+)/\u$1/g' *
This will capitalize all words except "hello" and words beginning with "t".
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
Cleans all files in /tmp that have been accessed at least 2 days ago.
Searches Google, but requires no "", and will also search all terms input in the CL, eg:
> google foo bar
returns search URL "http://www.google.com/search?q=foo%20bar"
You could also use awk to replace all spaces with a +, which is how the Google search handles spaces, but that makes it more than one line.
Shows all block devices in a tree with descruptions of what they are.
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"
}
This is super fast and an easy way to test your terminal for 256 color support. Unlike alot of info about changing colors in the terminal, this uses the ncurses termcap/terminfo database to determine the escape codes used to generate the colors for a specific TERM. That means you can switch your terminal and then run this to check the real output.
$ tset xterm-256color
at any rate that is some super lean code!
Here it is in function form to stick in your .bash_profile
aa_256 ()
{
( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;
for i in {0..256};
do
o=00$i;
echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;
done )
}
From my bash_profile: http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html