Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Dec 2019 09:01:58 -0600
From:      Valeri Galtsev <galtsev@kicp.uchicago.edu>
To:        freebsd-questions@freebsd.org
Subject:   Re: Counter in sh inside loop, value "encapsulation"
Message-ID:  <41e9293d-eb85-6476-8a23-198c6b5a477e@kicp.uchicago.edu>
In-Reply-To: <20191205073531.cb2a23ac.freebsd@edvax.de>
References:  <20191204181300.8dd0e03c.freebsd@edvax.de> <slrnqug5mi.srf.naddy@lorvorc.mips.inka.de> <20191205051145.78f9a805.freebsd@edvax.de> <20191205073531.cb2a23ac.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help


On 2019-12-05 00:35, Polytropon wrote:
> For further reference, the simple solution is always the best one.
> I now have the following:
> 
> 	COUNT=0
> 	for URL in `grep "^https" ${INFILE}`; do
> 		process ${URL}
> 		if [ $? -eq 0 ]; then
> 			COUNT=`expr ${COUNT} + 1`
> 		fi
> 	done
> 	echo "URLs processed: ${COUNT}"
> 
> There now is no piping step (and therefore no subshell) involved.
> This works and can be easily extended (more preprocessing from
> the input list file).

Thank you! You took some rust off my use of sh (I usually write scripts 
in bash).

Valeri

> 
> I have no idea why I didn't think of this in the first place... :-)
> 
> 
> 

-- 
++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41e9293d-eb85-6476-8a23-198c6b5a477e>