Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Feb 2000 16:41:41 -0600
From:      "Darryl Hoar" <darryl@osborne-ind.com>
To:        "'Mark Ovens'" <mark@dogma.freebsd-uk.eu.org>
Cc:        <freebsd-questions@freebsd.org>
Subject:   RE: OFF TOPIC - Shell Script Question
Message-ID:  <001201bf7285$ab614a40$070101c0@ruraltel.net>
In-Reply-To: <20000208211737.C329@marder-1>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for all the responses.  Here is what I did:

create a file with owner execute permissions.

#!/bin/sh
for i in `ls -lt | grep $1 | awk '{print $9}'`
do
  mv $i /home/darryl/test
done

Ran this with the following:
bigcat> ./myscript 1995

this moved all the files dated 1995 to the directory.

Once again thanks to all.

-- Darryl

-----Original Message-----
From: Mark Ovens [mailto:mark@dogma.freebsd-uk.eu.org]
Sent: Tuesday, February 08, 2000 3:18 PM
To: Darryl Hoar
Cc: freebsd-questions@freebsd.org
Subject: Re: OFF TOPIC - Shell Script Question


On Tue, Feb 08, 2000 at 02:34:25PM -0600, Darryl Hoar wrote:
> Greetings,
> I have a directory with a ton of files in it.  I need to move some of
> them to another
> directory.  Here's what I'm thinking:
>
> ls -tl | grep '1999' | awk '{print "mv " $9 " /home/darryl/test"}'
>
> but it does not 'execute' the mv command.  How do I get this cooking ?
>

Try

	$ for i in `ls -lt | grep 1999 | awk '{print $9}'`
	> do
	> mv $i /home/darryl/test
	> done
	$

> BTW, I don't plan on doing this a bunch, so I would preferr Not to
> install, learn
> perl.  Instead, use the shell.
>
> thanks,
>
> Darryl Hoar
> Computer Programmer / Systems Analyst
> Osborne Industries, Inc.
> darryl@osborne-ind.com
> (785) 346-2192
>
> PS.  If perls the only ticket, then I'll install and learn it.
>
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

--
	Microsoft: Where do you want to go today?
	Linux:     Where do you want to go tomorrow?
	BSD:       Are you guys coming, or what?
			              -Poster at LinuxWorld 2000
________________________________________________________________
      FreeBSD - The Power To Serve http://www.freebsd.org
      My Webpage http://ukug.uk.freebsd.org/~mark/
mailto:mark@ukug.uk.freebsd.org             http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001201bf7285$ab614a40$070101c0>