Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Feb 2000 23:09:28 -0800 (PST)
From:      David Kirchner <dpk@nwserv.com>
To:        Darryl Hoar <darryl@osborne-ind.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: OFF TOPIC - Shell Script Question
Message-ID:  <Pine.BSF.4.21.0002082300570.79387-100000@web2.sea.nwserv.com>
In-Reply-To: <001101bf7273$e44dc250$070101c0@ruraltel.net>

next in thread | previous in thread | raw e-mail | index | archive | help

On Tue, 8 Feb 2000, 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 ?

You can run the output of your command through sh:

ls -tl | ... | ... > file
sh file

or

ls -tl | ... | ... | sh

If you want to see some verbose output, change 'sh' to 'sh -x'.

There are a couple more ways you can perform the same command to multiple
files. Check out 'find' and its -exec flag.

-- 
David Kirchner - dpk@nwserv.com
Northwest Web Services - http://www.nwserv.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?Pine.BSF.4.21.0002082300570.79387-100000>