Terminal Heroes – 4 – regexpias lair
Let’s drop a little humor in this time…
You, brave Terminal Hero, shall kill -9 the daemon that has hidden itself in one of those files! We don’t know in which file you can find it though! We’re running out of time! The kingdom of GNU will be rm -rf‘d if you won’t make it in time!!! Luckily as a level 99 human root, have all the tools to find and exterminate the dragon in no time! So let’s get greping.
-
lair1 lair2 lair3 ……. lair1336
-
[ktoso@lairs ~]$ ls -l | wc -l
-
1337
-
[ktoso@lairs ~]$ find . -exec grep "Regexpia" '{}' \; -print
-
Regexpia is in this file
-
./lair1270
-
[ktoso@lairs ~]$ kill_dragon_inside lair1270
Ok, enough joking…This post is all about this one-liner:find . -exec grep "Onyxia" '{}' \; -print
It allows you to search all files (including sub directories) for the ones with the specified string inside them. It proved helpful to me as i had to get one *.php file from a photorec recovered bunch of files (some thousands of them…)…
Hope you had as much fun reading this as I had posting, and also that it might prove usefull to you. I found this on snipplr by the way, I really recommend this website!
PS: The title just sounds too awesome i think… If you didn’t get it, it’s about Onyxia’s Lair from World of Warcraft :-)


January 17th, 2010 at 15:00
Nice story!
One thought about the one-liner: in such situations I type something like:
$ find . | xargs grep “Onyxia”
This limits number of greps needed to start to 1 and is much easier to type!
January 17th, 2010 at 16:23
Ah yes! Your one-liner is much more elegant and quicker, thanks for sharing it – I’ll surely use your version from now on… :-)
Thanks a lot for your response!