Topics

Archives

Handy References

Uncategorized

« Previous Entries Next Entries »

Finding total number of lines in multiple files

Thursday, October 29th, 2009

find ./ -name “http_load_urls_*” -print0 | xargs -0 wc -l

Yet another one line shell script :)

Monday, October 26th, 2009

grep -R ‘>1254511748.80104′ * | awk -F: ‘{print $1}’ > filename; filename=$(head -1 filename); grep -n ‘%idle’ $filename | awk -F: ‘{print $1 + 13}’ > linenum; sed -i ‘s/^/head -/g’ linenum; sedfilename=$(head -1 filename | sed ‘s/\//\\\//g’); sed -i “s/$/ $sedfilename | tail -1 /g” linenum; chmod 755 linenum; ./linenum | sed ‘s/^.*”>//g’ | [...]

Now that’s a one liner…

Wednesday, October 21st, 2009

grep -R -n ‘pgpgin/s’ * | grep ‘:16′ | awk -F: ‘{printf “file=”$1″\n pagein=$(head -”$2 + 12″ “$1″ |\ tail -1 | sed \”s/^.*Number\\\”\>//g\” | sed \”s/\<.*$//g\”) \n echo \$file \t \$pagein \n”}’ \ > pagein.bash; ./pagein.bash > page_in.txt; sed -i ‘s/.xml//g’ page_in.txt; sed -i ‘s/K_.*_/K /g’ \ page_in.txt; sed -i ‘s/M_.*_/M /g’ page_in.txt; sed [...]

Another cool little line…

Monday, October 5th, 2009

While creating a bunch of files, counts them and subtracts our fixed starting count: var=$(ls /raid | grep -c .) ; echo “$var – 192000″ | bc

Automating process killing…

Thursday, September 10th, 2009

The one-liner:  ps -ef | grep http_load | grep -v grep | awk ‘{print $2}’ | xargs kill The in-depth explanation: ps -ef | grep http_load lists all the processes with http_load in their name.  That’s the processes I want to kill. grep -v grep removes from that process list the process which listed the [...]

To be organized later…

Tuesday, September 8th, 2009

http://online.wsj.com/article/SB125200842406984303.html#articleTabs=article About data mining against criminals / terrorists

Cool little nmap command

Friday, September 4th, 2009

Good for scanning systems, even with firewall up: nmap -sP -PT80 192.168.1.0/24

What interfaces are being loaded at boot?

Tuesday, September 1st, 2009

dmesg | grep [driver] (This will also tell you the MAC addresses being used)

Extracting an RPM…

Wednesday, August 12th, 2009

rpm2cpio package.rpm | cpio -id That was easy.

shell math and alphanumeric sizes…

Thursday, July 30th, 2009

Just because I really like the elegance: preload_count=$(echo “($preload_size) / ($file_size)” | sed ‘s/K/ * 1024/g’ | sed ‘s/M/ * 1048576/g’ |\ sed ‘s/G/ * 1073741824/g’ | bc)

« Previous Entries Next Entries »