bash: Redirect output to virtual file

Sven Bachmann
Bash has a cool feature, it allows you to redirect the output of an application to a virtual file. With this its for example possible to fast-diff two directories. The old way would look like this: ls dir1/ > directory_1.txt ls dir2/ > directory_2.txt diff directory_1.txt directory_2.txt But with bash (and maybe some other shells) you can do the following: diff <(ls dir1/) <(ls dir2/)

[Bash] Remaining Battery Power as Prompt

Sven Bachmann
Hi, as seen at my pal Philipp, I also wanted to see the current battery power in the bash prompt. So here is a script which works fine on my X60s. #!/bin/bash REMAIN=`grep "remaining capacity" /proc/acpi/battery/BAT0/state | sed 's/remaining capacity:\(.*\)mWh/\1/'` FULL=`grep "last full capacity" /proc/acpi/battery/BAT0/info | sed 's/last full capacity:\(.*\)mWh/\1/'` echo $[ $REMAIN * 100 / $FULL ]`</blockquote> Just save it for example in your home directory as and make it executable with chmod +x bat.