Etusivu Liisa Autot Juhlat Kotiteatteri Kuvaaminen Sukeltaminen Matkailu Musiikki Ohjelmat Roolipelit Ruuanvalmistus Tietokoneet Arkistot Sekalainen Sivuhakemisto |
ShelltricksFile rename with running orderRemove non-SVN files Remove nonexisting files from SVN Tail a httpd-log with resolve Print the load average and temperature of mobo/CPU in a console
File rename with running order CNT=1; for i in *.jpg; do j=`printf "%.03d" ${CNT}`; mv -i "${i}" something-${j}.jpg ;CNT=$(($CNT+1)); done
Remove non-SVN files svn st | grep ^? | cut -c 8- | xargs rm -rf
Remove nonexisting files from SVN for i in `svn st | grep ^! | cut -c 8-`; do svn rm ${i}; done
Tail a httpd-log with resolve #!/usr/bin/perl while( <> ) { chomp; if( m/^(\S*)\s*(\S*)\s+(\S*)\s*\[(\S*)\s*(\S*)\]\s*"(\w*)\s*(.*)\s+(\S*)"\s*(\S*)\s*(\S*)\s*"(.*)"\s*"(.*)"\s*(\S*)/ ) { $ipaddress = $1; ( $dateString = $4 ) =~ s/\[//; ( $request = $7 ) =~ s/"//; #" open( HOST, "/usr/bin/host $ipaddress|" ); while( $foo = <HOST> ) { if( ! m/not\sfound/ ) { $foo =~m/\s(\S+)\.$/; $ipaddress = $1; } print( $dateString . " " . $ipaddress . " -> " . $request . "\n" ); } } }Then run it like so: tail -f /path/to/logfile.log | perlscript.pl |
Copyright (c) Paul-Erik Törrönen unless explicitly mentioned otherwise