Dobrica Pavlinušić's random unstructured stuff
Shell: Revision 7

Welcome to scratch pad of usefull shell snippets



remove all php4 packages with apt-get

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

use socat as simple serial program

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

list first ten files from srchives

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"

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 :-)

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

port forwarder using socat

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