Date: Tue, 08 Feb 2000 19:14:53 -0800 From: Ludwig Pummer <ludwigp@bigfoot.com> To: darryl@osborne-ind.com Cc: freebsd-questions@freebsd.org Subject: Re: OFF TOPIC - Shell Script Question Message-ID: <38A0DBAD.44AF1595@bigfoot.com> References: <001101bf7273$e44dc250$070101c0@ruraltel.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 ? > > BTW, I don't plan on doing this a bunch, so I would preferr Not to > install, learn > perl. Instead, use the shell. If mv would let you invert the order of its arguments, an ls | awk | xargs | mv pipe would take care of this, but it doesn't so (I did this from tcsh): If the filenames actually have 1999 in them: ( echo '#\!/bin/sh' ; ls -tl | awk '/1999/ {print "mv " $9 " /home/darryl/test"}' ) > mvfile sh mvfile If the file's mtime is 199 and you don't care about what's in the filename: ( echo '#\!/bin/sh' ; ls -Ttl | awk '($9 == 1999) {print "mv " $10 " new"}' ) > mvfile sh mvfile Note that these will fail for files whose filenames contain spaces. --Ludwig Pummer <ludwigp@bigfoot.com> <lspummer@ucdavis.edu> 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?38A0DBAD.44AF1595>