Friday, October 8, 2010

Helpfull UNIX stuff

Find not matches http in files
$ find -xdev -type f -name "*.cs" | while read -r; do file="${REPLY}"; grep -q
'http' "$file" || echo "File '$file' matches"; done


Find
find -xdev -type f -print0 | xargs -r0 egrep -i --files-with-matches 'jdbc\.url'

Test regular expression
egrep -i '^[A-Z]\.?

Find all processes with name java
ps -u -C java

Replace word in group of files
sed 's#oldworld#newworld#g' *.java

Friday, October 1, 2010

Random bash password generation

head /dev/urandom | uuencode -m - | sed -n 2p | cut -c1-${1:-8};