Richard H. Schwartz's thoughts on Lotus messaging and collaboration technology, news, politics, and whatever else comes to mind.
PermaLinkfind, grep, xargs, awk, and sed, Oh my!05:30:23 PM

It has been a loooong time since I learned basic Unix shell scripting. In fact, it's been a long time since I forgot 95% of it. Therefore, I am giving myself a cookie for figuring this out today.

find . -name "*.xml" | grep -v test | xargs grep '\${env' | awk '{print substr($0,index($0,"{")+1)}'| sed 's/}.*//' | sort | uniq

P.S. I can't imagine how long it would have taken to figure it out without google and stackoverflow.

P.P.S. One or more of my friends is surely thinking "I could have done that with about 20 characters of perl". Perl makes my brain hurt, so keep it to yourselves!

P.P.P.S. Any of you who looked at that and immediately said "Oh, sure... He's printing all the environment variable references in his non-test ant scripts"... You win a prize. (And I hate you!)

P.P.P.P.S. Yes, I know it's been nearly two years since I posted anything at all on this blog. Shame on me. And if anyone's actually reading this without having followed the link I'm about to post on Facebook, I'll be surprised. But I couldn't bring myself to post this directly on Facebook, and it had to go somewhere!


Monthly Archive
Responses Elsewhere

About The Schwartz


All opinions expressed here are my own, and do not represent positions of my employer.