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

Re: scripting question

On Die, 15 Apr 2003 at 17:18 (-0700), Maria Rodriguez wrote:
> Hello!
> I've got a scripting question for you bash lovers out there.
> I have a directory that has a lot of subdirectories, only one of which I want to keep.  Let's say I want to keep only the "B" subdirectory below:
> /path/to/A
> /path/to/B
> /path/to/C
> Is there a way >>> on the command line <<< to remove all the directories other than B?  I thought there might be a way to do this with "find" but nothing I've tried yet seems to work.

cd /path && rm -rf [^B]* B?*

First pattern matches all filenames _not_ beginning with a B and
second matches all filenames beginning with a B, but having at least
two characters in their name.


Reply to: