in reply to Re: Write a file if grep finds a pattern?
in thread Write a file if grep finds a pattern?

?
if( `grep -l error /temp/logbook.log > /dev/null`) `echo 'ok!' > /temp/ok.txt` }

Replies are listed 'Best First'.
Re^3: Write a file if grep finds a pattern?
by JavaFan (Canon) on Nov 19, 2010 at 13:29 UTC
    Let's say, you're asking the shell to run grep and discard the output, then collect the output, and if you say anything, you ask the shell to put something in a file, all to show your "Perl" program is as long as a shell one?

    It doesn't even work this way.

    But if you want to golf (if you have 'ack', shave off one character):

    grep error c:/temp/logbook.log&&echo 'ok!'>/temp/ok.txt
    Slapping backquotes on it to make it "Perl", still is two characters more.