From owner-freebsd-questions@FreeBSD.ORG Thu Apr 3 10:13:57 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 0140E37B401 for ; Thu, 3 Apr 2003 10:13:57 -0800 (PST) Received: from aphrodite.gwi.net (aphrodite.gwi.net [207.5.128.164]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00E9443F3F for ; Thu, 3 Apr 2003 10:13:56 -0800 (PST) (envelope-from ah54@httpsite.com) Received: from andy.gwi.net (blake.gwi.net [207.5.142.8]) by aphrodite.gwi.net (8.12.6/8.12.6) with ESMTP id h33IDkK4003292; Thu, 3 Apr 2003 13:13:50 -0500 (EST) (envelope-from ah54@httpsite.com) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200304031147.30097.mbettinger@championelevators.com> X-Homepage: http://www.nachoz.com X-PGP-Key: RSA-1024 http://www.nachoz.com/andy.pub X-System-Info-DB: PostgreSQL-7.3.2 X-System-Info-RT: rt-3-0-0 X-System-Info-WM: windowmaker-0.80.2 X-System-Info-httpd: apache-1.3.27_4 X-System-Info-OS: FreeBSD 4.7-RELEASE-p6 Date: Thu, 03 Apr 2003 13:13:55 -0500 (EST) Sender: aharriso@andy.gwi.net From: Andy Harrison To: Matthew Bettinger cc: freebsd-questions@freebsd.org Subject: Re: #!sh grep and move files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2003 18:13:57 -0000 -----BEGIN PGP SIGNED MESSAGE----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On 03-Apr-2003, Matthew Bettinger wrote message "#!sh grep and move files" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 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 > > Change it to this and it should be ok `find /dir -type f -name 'LB*' | xargs grep -l '^1~TA'` ~~ Andy Harrison ah##@httpsite.com ICQ: 123472 AIM/Y!: AHinMaine [full headers for details] -----BEGIN PGP SIGNATURE----- Version: PGP 6.5.8 iQCVAwUBPox54lPEkLgodAWVAQH46AQAm74ObqXNVSxa4vyuaMQRrlLi7dq6Tx7M 0oIxeG6mifhd92YWLzmYg75urR3dXzZVqIcLJ2EDztQwYxbDjNWNDXlyaEKvxZCq kSycD5Xo9gJTlz+A4Og75wdxBSoQmEU+pFWuIW10+FN72trBTI8Inbtt1TL7fGSz oHMNQFfR1cY= =X/DZ -----END PGP SIGNATURE-----