[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New feature request for cp to flatten directory
From: |
Bob Proulx |
Subject: |
Re: New feature request for cp to flatten directory |
Date: |
Thu, 13 Dec 2007 09:05:31 -0700 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Todd Andrews wrote:
> 1) The command line using find gets a bit complicated when you need to
> take into account file names with spaces, quotes, etc.
The 'find' command Eric proposed handled file names with spaces,
quotes, etc. okay. There was no further complication.
> Using a variation on what Pádraig Brady sent will take care of this:
>
> find data -type f -print0 | xargs -r0 cp -av --backup=numbered
> --target-directory=alldata
This can be written using POSIX standard 'find' syntax (which handles
correctly names with spaces, quotes, etc.) as:
find data -type f -exec cp -pv --backup=numbered --target-directory=alldata
{} +
Using 'find' is very powerful because it works with other programs
without needing to modify those other programs. It applies a standard
way of operating across files in the filesystem.
> 2) Eric wrote, "Thanks for the suggestion. However, it seems like this
> is already possible with existing tools, so why add the bloat?"
>
> Because I'm sure you'd agree having to use find + xargs + cp is not very
> intuitive compared with "cp -pr --flatten data -t alldata"
First no one suggested using xargs. (Although it is a traditional
tool in this space. But find does it internally now and is
standardized.) Second while I agree that the number of characters
typed on the command line might be slightly less I think it is well
worthwhile to use an interface that can be applied uniformly to a
large set of utilities in a standard way.
Trying to jam all possible behavior into all possible programs is
counter to the Unix philosophy.
http://www.faqs.org/docs/artu/ch01s06.html
http://en.wikipedia.org/wiki/Unix_philosophy
The way to design powerful programs is not to rewrite them with every
possible behavior. The way to design powerful programs is to write
them so that they can be used in combination in powerful new ways
without needing to be rewritten.
Bob