Troca de conhecimentos sobre o uso da linha de comando e referencia direta ao site commandlinefu.com.
View the newest xkcd comic.
27 de Novembro de 2009, 0:00 - sem comentários ainda$ xkcd(){ local f=$(curl -s http://xkcd.com/);display $(echo "$f"|grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)');echo "$f"|awk '/
by David Winterbottom (codeinthehole.com)
a trash function for bash
25 de Novembro de 2009, 0:00 - sem comentários ainda$ trash <file>
Every rm'ed a file you needed? Of course you haven't. But I have. I got sick of it so I created a bash function. Here it is. It'll put trashed files into a $HOME/.Trash/"date" folder according to the date. I have rm aliased to it as well in my bashrc so that I still use the rm command. It'll choke if you attempt to trash a directory if that directory name is already in the Trash. This rarely happens in my case but it's easy enough to add another test and to mv the old dir if necessary.
function trash(){
if [ -z "$*" ] ; then
echo "Usage: trash filename"
else
DATE=$( date +%F )
[ -d "${HOME}/.Trash/${DATE}" ] || mkdir -p ${HOME}/.Trash/${DATE}
for FILE in $@ ; do
mv "${FILE}" "${HOME}/.Trash/${DATE}"
echo "${FILE} trashed!"
done
fi
}
by David Winterbottom (codeinthehole.com)
A robust, modular log coloriser
23 de Novembro de 2009, 0:00 - sem comentários ainda$ ccze
CCZE is a robust and modular log coloriser, with plugins for apm, exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, vsftpd, xferlog and more.
Examples:
tail -f /var/log/messages | ccze -A
tail -f /var/log/exim4/mainlog | ccze -A
by David Winterbottom (codeinthehole.com)
Make sure a script is run in a terminal.
20 de Novembro de 2009, 0:00 - sem comentários ainda$ [ -t 0 ] || exit 1
Exit with error if script is not run in a terminal
by David Winterbottom (codeinthehole.com)
Create an audio test CD of sine waves from 1 to 99 Hz
17 de Novembro de 2009, 0:00 - sem comentários ainda$ (echo CD_DA; for f in {01..99}; do echo "$f Hz">&2; sox -nt cdda -r44100 -c2 $f.cdda synth 30 sine $f; echo TRACK AUDIO; echo FILE \"$f.cdda\" 0; done) > cdrdao.toc && cdrdao write cdrdao.toc && rm ??.cdda cdrdao.toc
This command creates and burns a gapless audio CD with 99 tracks. Each track is a 30 second sine wave, the first is 1 Hz, the second 2 Hz, and so on, up to 99 Hz. This is useful for testing audio systems (how low can your bass go?) and for creating the constant vibrations needed to make non-Newtonian fluids (like cornstarch and water) crawl around.
Note, this temporarily creates 500MB of .cdda files in the current directory. If you don't use the "rm" at the end of the command, you can burn more disks using
cdrdao write cdrdao.toc
Prerequisites: a blank CD-R in /dev/cdrw, sox (http://sox.sourceforge.net/), and cdrdao (http://cdrdao.sourceforge.net/). I'm also assuming a recent version of bash for the brace expansion (which just looks nicer than using seq(1), but isn't necessary).
by David Winterbottom (codeinthehole.com)
Listen to BBC Radio from the command line.
14 de Novembro de 2009, 0:00 - sem comentários ainda$ bbcradio() { local s;echo "Select a station:";select s in 1 1x 2 3 4 5 6 7 "Asian Network an" "Nations & Local lcl";do break;done;s=($s);mplayer -playlist "http://www.bbc.co.uk/radio/listen/live/r"${s[@]: -1}".asx";}
This command lets you select from 10 different BBC stations. When one is chosen, it streams it with mplayer.
Requires: mplayer with wma support.
by David Winterbottom (codeinthehole.com)
Split a tarball into multiple parts
10 de Novembro de 2009, 0:00 - sem comentários ainda$ tar cf - <dir>|split -b<max_size>M - <name>.tar.
Create a tar file in multiple parts if it's to large for a single disk, your filesystem, etc.
Rejoin later with `cat .tar.*|tar xf -`
by David Winterbottom (codeinthehole.com)
Clean your broken terminal
9 de Novembro de 2009, 0:00 - sem comentários ainda$ stty sane
When some console full-screen program (minicom, vi, some installers) breaks down your terminal, try this command to revert all options to "sane" settings (sane is a built-in combo of a lot of stty options)
by David Winterbottom (codeinthehole.com)
Press Any Key to Continue
5 de Novembro de 2009, 0:00 - sem comentários ainda$ read -sn 1 -p "Press any key to continue..."
Halt script progress until a key has been pressed.
Source: http://bash-hackers.org/wiki/doku.php/mirroring/bashfaq/065
by David Winterbottom (codeinthehole.com)
geoip information
4 de Novembro de 2009, 0:00 - sem comentários ainda$ curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>][^>]*>//g'
Not my script. Belongs to mathewbauer. Used without his permission.
This script gives a single line as shown in the sample output.
NOTE: I have blanked out the IP address for obvious security reasons. But you will get whatever is your IP if you run the script.
Tested working in bash.
by David Winterbottom (codeinthehole.com)