From owner-freebsd-questions@FreeBSD.ORG Thu Apr 3 09:52:36 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C34A937B401 for ; Thu, 3 Apr 2003 09:52:36 -0800 (PST) Received: from cobalt.4gl.com (cobalt.4gl.com [66.212.110.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0963643F85 for ; Thu, 3 Apr 2003 09:52:36 -0800 (PST) (envelope-from mbettinger@championelevators.com) Received: from helpdesk.championelevators.com (node-97-98.4gl.com [66.212.97.98] (may be forged)) by cobalt.4gl.com (8.9.3/8.9.3) with ESMTP id MAA02962 for ; Thu, 3 Apr 2003 12:04:50 -0600 From: Matthew Bettinger Organization: Champion Elevators, inc. To: freebsd-questions@freebsd.org Date: Thu, 3 Apr 2003 11:47:30 -0600 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304031147.30097.mbettinger@championelevators.com> Subject: #!sh grep and move files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: mbettinger@championelevators.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2003 17:52:37 -0000 Hello, I am trying to find the best way to search through several thousand files and move some to a different directory. The files are all prefixed with LB. Like, LBX99.DAT141683. These are data transactions and contain one line. The lines i am trying to search for all begin with 1~TA~ (standing for timeand attendance labor transactions) I've tried #!/usr/bin/sh for x in `find /dir -type f -exec grep '1~TA' [] \;` do mv $x /newdir done ---------------------------- There seems to be something i am missing like some output redirection or an ls listing... probably alot more. I know this can be done in a one liner somehow but I need it to be executed from cron. Thanks for any assistance. Matt