Building Blocks
From Productiveprogrammer
Contents |
[edit] Rockin' Command Lines Captured from the Wild
[edit] Find ZIP Files Except the Ones You Don't Want
Find all ZIP files from this directory down except the ones in the './web' directory and delete them (if you want confirmed deletion, use -ok instead of -exec):
find . -name *.zip -not -regex "..web..*" -exec rm "{}" \;
[edit] Remove all SVN gunk recursively
Find all .svn directories under some directory and remove them.
rm -rf `find . -type d -name .svn`
OR, if you have not checked out the code yet, but plan to check it out and then delete the .svn directories, it's easier to simply do this:
svn export your_svn_url
[edit] Exception Counting Example from the book simplified
egrep -o '[\w.]+Exception' | sort | uniq -c
uniq -c prepends count of occurrence before string
[edit] Process substitution rocks!
If it is expected that log.txt contain lines of the form 'Message-Num: N' where N is 1 to 1000, here's a way to find what Message-Nums are missing, if any:
comm -13 <(grep Message-Num log.txt | cut -f2 -d ' ') <(seq 1000)
The <(...) construct is process substitution, available in bash, among others.
[edit] In the Beginning...
Great, great essay by Neal Stephson, In the Beginning Was the Command Line
