Steven, This is exactly what I am having to do at the moment. Unfortunately, I just pushed my code through the release process and it has gone live. I'll update my code, but wait until there is a more pressing need to go live with it before I go through this hassle again. It only runs early in the morning every Sunday so speed is not an issue.
Thanks! Andy On Mon, Feb 16, 2009 at 11:03 AM, Steven S. Critchfield <[email protected]> wrote: > > Okay, I just had to share this one. > > I have a process I normally have to do a few times a month that moves files > from one directory into a dated storage dir. Wouldn't be a hard problem but > the directory grows longer than can be used by simple argument expansion. > So we use a ls piped to grep and hand off to xargs. Problem was that due to > the normal usage of mv being "mv source dest" I had to use xargs -i to get > mv happy. > > ls | grep TXT | xargs -i mv {} dest/ > > Well today when I tried yet again to get xargs to place more than one item > in the source section of the mv, I ran across an interesting solution that > I didn't think about. I had fixated on making xargs do all the work that I > didn't think about what could I do differently with mv to get the problem > solved. It seems cp and mv both support a --target-directory option that > lets you put the dest argument before the sources, and then you can turn > xargs loose to do it's normal operation. > > ls | grep TXT | xargs mv --target-directory=dest/ > > This allows xargs to pack as many source files into each command as it can, > instead of the original that ran mv for every source file. Sped up the run > time by several minutes. > > Just a little bit of reinforcement that occasionally when you are banging > your head on a problem one way, you might need to look at the other parts > to see if they can help you out. > > -- > Steven Critchfield [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NLUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en -~----------~----~----~----~------~----~------~--~---
