From owner-freebsd-questions@FreeBSD.ORG Thu Sep 20 02:12:00 2012 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 77C99106566C for ; Thu, 20 Sep 2012 02:12:00 +0000 (UTC) (envelope-from martin@dc.cis.okstate.edu) Received: from x.it.okstate.edu (x.it.okstate.edu [139.78.2.13]) by mx1.freebsd.org (Postfix) with ESMTP id 31E528FC0A for ; Thu, 20 Sep 2012 02:11:59 +0000 (UTC) Received: from dc.cis.okstate.edu (localhost [127.0.0.1]) by x.it.okstate.edu (8.14.5/8.14.5) with ESMTP id q8K23Bv5034624 for ; Wed, 19 Sep 2012 21:03:11 -0500 (CDT) (envelope-from martin@dc.cis.okstate.edu) Message-Id: <201209200203.q8K23Bv5034624@x.it.okstate.edu> To: FreeBSD Questions Date: Wed, 19 Sep 2012 21:03:11 -0500 From: Martin McCormick Subject: bash Shell Scripting 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, 20 Sep 2012 02:12:00 -0000 I just discovered a knowledge deficiency on my part that I can't seem to resolve. If one writes a loop of the following form: #!/usr/local/bin/bash ls -LF |grep \/ >/tmp/files while read dirname; do cd $dirname #Do whatever commands to be repeated in each directory. done < /tmp/files This works quite well but it is shall we say sloppy because it creates a file that then must be cleaned up and its name needs to be made unique, etc. The standard output of the `ls -LF |grep \/` command needs to look like a file and all should be well. I thought the < redirection would pickup the standard output. Thanks for ideas. Martin McCormick