From owner-freebsd-questions@FreeBSD.ORG Thu May 6 01:25:47 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4A93C106564A for ; Thu, 6 May 2010 01:25:47 +0000 (UTC) (envelope-from evuraan@gmail.com) Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com [74.125.83.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2406F8FC0C for ; Thu, 6 May 2010 01:25:46 +0000 (UTC) Received: by pvc30 with SMTP id 30so1215247pvc.13 for ; Wed, 05 May 2010 18:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=WJBOcHzgDxj/Siv+38EbuMcY99X83jor/Gw9QAOzlw4=; b=YJ6e1UOGMe/x+ja4u9vNgY4mrz8gobmLImrpt8i4iOymVBIBZ4nJ6C4dB+Eyrs6v4i u+UfKmydyJqKjWwNdw9lNKUIVS5iQFle32YOoGh1j3VPEitsEsScRNHgTtQpZwnoHXGG A/VrO4NQtKVjVr6rrff68QRu8KP7qWQEtF0Lg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=wy5EgBrMq0amXv+2ep0p8+1n0ULgnitDwUnVc2bbq9jxWC5AEWb64dUEltPuP97L8k Kjbffa3B2Adqhx4tTJU+pLB0qTDgLh9oeZOc93yCU5n0mswbgQmPcc/PiFb6GZKs/DQL pts8sUil+uktXwluzjXMyz6JkjHWqnL0FUlNg= MIME-Version: 1.0 Received: by 10.142.60.21 with SMTP id i21mr320445wfa.132.1273109144737; Wed, 05 May 2010 18:25:44 -0700 (PDT) Received: by 10.142.142.9 with HTTP; Wed, 5 May 2010 18:25:44 -0700 (PDT) Date: Wed, 5 May 2010 18:25:44 -0700 Message-ID: From: Evuraan To: Paul Hoffman Content-Type: text/plain; charset=UTF-8 Cc: freebsd-questions@freebsd.org Subject: bash while read question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2010 01:25:47 -0000 I cant figure out why the variable in in loop2 does not hike to +1? (its a friday, i am dazed, I admit. but this should not be a mystery!) any help would be much appreciated. $ cat loop1 #! /bin/bash date > /tmp/somefile b="1" while read blah; do let b=(b+1) done < /tmp/somefile echo "variable is $b" $ cat loop2 #! /bin/bash date > /tmp/somefile b="1" cat /tmp/somefile | while read blah; do let b=(b+1) done echo "variable is $b" $ ./loop1 variable is 2 $ ./loop2 variable is 1