Uso do comando grep
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 15 de Junho de 1997
Alguns recursos úteis do comando grep:
1) Pesquisa de múltiplos argumentos:
% grep "arg1|arg2|arg3" file1 file2 file3 file4
2) Pesquisa de strings, independentemente se maiúsculas ou minúsculas:
% grep -i arg file1 file2 file3
No primeiro exemplo, os arquivos file1, file2 ... até file4
serão pesquisados para se determinar a ocorrência de qualquer um dos
argumentos fornecidos entre aspas (arg1, arg2 ou arg3).
No segundo exemplo, a flag "-i" indica que se quer achar o argumento
arg1 nos arquivos fornecidos, independentemente se maiúsculos ou minúsculos.
Desta forma, Arg1, aRg1, ARG1 e qualquer combinação possível de letras
maiúsculas ou minúsculas, satisfariam a pesquisa.
Dica Humorística :-)
BASTARD OPERATOR FROM HELL #10
I get invited to a lecture as a guest speaker in "Computing Operations Fund-
amentals", so I leave the control room in the capable hands of Sam, the
janitor and cruise on down.
The lecture starts and goes ok, then there's a 10 minute period where students
get to ask a "real operator" questions that they have about operations.
I get out my pad and pen.
"Before we get started" I say, "could you just call out your username before
you ask me a question, I find it easier to apply your problem to terms you
would understand better"
The lecturer eats all this up - the personal touch really gets to them.
"First Question, You over there.."
"What do you think of the privacy of individuals on a shared system?"
"What was your username please?"
"Computer Privacy... Hmmm. This is a toughy really. You mean stuff like
reading the email between you and your counsellor about you not wanting to
come out of the closet?"
"AH. Well, he seems to have left - must have picked a bad COMPLETELY RANDOM
example. Next question. You, over there..."
"CMS1136. I was.."
"Ah yes, 1136 the only person on campus who subscribes to alt.sex.buggery.by.
"It's purely for research purposes!"
"I'm sure it is. You do a lot of story posting for a researcher don't you?"
Two minutes later, the lecture theatre's empty.
That's the problem with students today, they just don't want to learn.
I go back to control and Sam's asleep at the console again. I think he's
after my job. I make a mental note to tap into the salary database and
cancel his health and accident insurance payments. You can't be too careful..
I put the phone on the hook for the first time this afternoon and it starts
ringing almost immediately. THAT'S IT! I redirect it to 911 catch a bit of
shuteye. That'll teach them. OOPS! Almost forgot to turn over the excuse
calendar. "STATIC FROM NYLON UNDERWEAR" Nope, too plausable - although in
some cases I could do an on-site check. Nah, can't be stuffed. I'll pick
another one. "STATIC FROM PLASTIC SLIDE RULES" Now THAT'S one with a
I un-redirect the phone and drag the rubbish bin so it rests on the printer's
stacker - another job well done. The phone rings - this could be the big one!
"Hi, Um, how do I spell-check my file?"
"Simple, just type `spell' and the filename"
I'm so bloody nice this morning. Especially as I know that my version of spell
introduces errors instead of detecting them. Things like changing friend to
freind and vice-versa. What the hell.
The phone rings - it's them again.
"There's something wrong with spell"
"What makes you think that?"
"Because my file is all corrupt now!"
"That doesn't sound like spell to me. Are you logged into thru PC?"
"Yes, but I can.."
"Please, leave the technical diagnosis to me... Now, is there a plastic ruler
somewhere on or in the desk?"
Hmm clunka<, yes..."
"Right. You've got a static buildup on your hard-drive caused by the changing
electrostatic field generated by the ruler - the same one that makes bits of
paper stick to it when you rub it up and down your arm..."
DUMMY MODE ON
"Oh. What do I do?"
"You know how you get paper off a ruler by hitting it on a table lots of times?
Well do that with your PC. Say 20 times - lift it about a foot off the desk &
Hmm, the screen went dark"
"That's ok, it's supposed to do that - keep going. And when you're finished,
do the screen as well, that static may have gone up the wires to it."
I hang up. I get up and go out to the public area to put honey in the floppy
drives when a guy who looked like Lee Harvey Oswald runs up to me and shoots
me, only the sound comes from the machine room, and I can hear the ex System-
Later, in the ambulance, I realise. I forgot to get the guys username...
Then everything goes dark
<spt (a) waikato ac nz> (Simon Travaglia)