Dobrica Pavlinušić's random unstructured stuff
Shell: Revision 7
Welcome to scratch pad of usefull shell snippets

{toc: }

^ remove all php4 packages with apt-get

.pre
dpkg -l | grep php4 | awk '{ print $2 }' | xargs apt-get remove -y
.pre

^ use socat as simple serial program

.pre
socat - /dev/ttyS0,b9600,echo=0,raw
.pre

^ list first ten files from srchives

.pre
ls *.tar.gz *.tgz | xargs -i sh -c "ls -hs '{}' ; echo ; tar tvfz '{}' | head -10 ; echo"

ls *.tar.bz2 *.tbz | xargs -i sh -c "ls -hs '{}' ; echo ; tar tvfj '{}' | head -10 ; echo"
.pre

> Yes, it sucks that `tar` doesn't know how to handle compression formats automatically...

^ tail recent logs and put output in file

Useful to take a quick view into last lines, reload page (and capture newly created errors/infos) and store that in single file for easy review (in vim :-)

.pre
tail -f /var/log/apache2/*.log | tee ~/log
.pre

^ port forwarder using socat

.pre
socat -d -d TCP4-LISTEN:1280,fork TCP4:192.168.212.5:80
.pre