[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about imports and cvs update

From: Spiro Trikaliotis
Subject: Re: about imports and cvs update
Date: Mon, 15 Mar 2010 20:47:46 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello Harry,

* On Sun, Mar 14, 2010 at 12:15:40PM -0500 Harry Putnam wrote:
> Spiro Trikaliotis <address@hidden> writes:
> Do you mind illustrating what you mean about the calls to `find'?

Ok. I assume there are no file names that are insecure to use on the
command line! The same holds true for directory names.

Then you can add all directories by using

$ find . -type d | grep -v \/CVS$ | tr \\n \\0 | xargs -0 -n 10 cvs add --

The "find" searches for every directory ("-type d") in the current
directory (".") and every sub-directory. The "grep" ensures we do not
handle CVS directories, if these exist. (Note: The "\/CVS$" filters out
("-v") every directory that ends with /CVS.)

Then, I use the file names as parameters for a "cvs add". This add all
directories. The "-n 10" ensures that no more than 10 directories are
used for every "cvs add" command.

The "tr \\n \\0" makes sure that we replace every newline (\n) with an
ASCII NUL (\0). The helps us for xargs, as we use the -0 option. This
way, if a directory contains a space, it is handled correctly.

Having done this, the directory structure was generated. Now, we can add
all the files:

$ find . -type f | grep -v \/CVS\/ | tr \\n \\0 | xargs -0 -n 10 cvs add --

We search files ("-type f"), leave out everything that is in a "CVS"
directory (grep -v \/CVS\/), then we replace every newline with NUL
again and give the output to a "cvs add" command.

I am doing this in two steps (first the directories, then the files), as
I am not sure if find actually guarantees that directories are output
before the files that are in them. Additonally, I can give different
options to "cvs add" for files and directories.

Otherwise, you might want to use something like:

$ find . | grep -v \/CVS\/ | grep -v \/CVS$ | tr \\n \\0 | xargs -0 -n 10 cvs 
add --

For all of this, there is one simple rule: Use at your own risk!


Spiro R. Trikaliotis                               

reply via email to

[Prev in Thread] Current Thread [Next in Thread]