Re: stop processing with 'if grep exit' ?

[email protected]
Newsgroups gmane.org.user-groups.slug.general
Message-ID <841txiyox9.wl%[email protected]>
>>>>> "lists" == lists  <[email protected]> writes:

lists> On Wed, March 19, 2014 5:43 pm, [email protected] wrote:
>> Yes, but I'd use &&

>> grep "test2" file2 && exit 0

lists> Peter,

lists> thanks again. can I include somewhere here 'echo 'helo' >>
lists> "$LOG"'

Can't see why not.

While testing, you can put
      exec 2> /tmp/alog$$
      set +x
near the start of the script to get a log of everything that happens
in a file in /tmp.  Get rid of the lines when you're sure it all works
though.

If you're doing that, then while testing if there are any lines that
you don't want to have their effect, but still want to see, put a
colon at the start.  : is a special command that does nothing --- but
lets you see what arguements would be expanded.

So
	if grep 'stuff3' somefile > /dev/null 2>&1
	then
	: mail -s "$someSubject" [email protected] <<-EOF
	Some email message
	
	.
EOF
	fi

will show the mail command with someSubject exanded in the log, but
will not actually send any mail.

Peter C





lists> -- SLUG - Sydney Linux User's Group Mailing List -
lists> http://slug.org.au/ Subscription info and FAQs:
lists> http://slug.org.au/faq/mailinglists.html
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.