Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'mv' all files containing a certain string to a sub-directory
- X-seq: zsh-users 10912
- From: Heinrich Götzger <goetzger@xxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: 'mv' all files containing a certain string to a sub-directory
- Date: Tue, 31 Oct 2006 14:59:16 +0100
- In-reply-to: <17393e3e0610310540y1f88b925r772dcce235bf0790@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns986D84207EE85zzappergmailcom@xxxxxxxxxxx> <45474ECD.7040309@xxxxxx> <17393e3e0610310540y1f88b925r772dcce235bf0790@xxxxxxxxxxxxxx>
Matt,
Matt Wozniski wrote:
>> Are you looking for smth like:
>>
>> find . -type f -exec grep -e "a certain string" {} \; -exec mv {} tmp \;
>>
>> HTH
>
> Heinrich's suggestion would move files both in the current directory
> and subdirectories that match your search string. If you only want
> the current directory, you should be fine to use a
>
> mv *somestring* tmp
this moves all files containig 'somestring' in it's filename, not in the
file itself, as I understood it and as it would in the former command.
But you are right, the find expressens prerequisite would be that it is
not allowd to have 2 or more files matching the grep with the same name
in different directories in '.'. Otherwise you would sould only find a
subset of files in tmp
And tmp should not be a subdirectory of the directory you are searching
in it would break with an error for moving the same file to itself
>
> ~Matt
>
> PS - Sorry Heinrich, I accidentally sent this to you instead of the
> list at first. My bad. :)
don't worry, happend to me 10 Minutes ago as well :-)
cheers
Heinrich
>
> On 10/31/06, Heinrich Götzger <goetzger@xxxxxx> wrote:
>> zzapper wrote:
>> > Hi
>> > I want to 'mv' all files containing a certain string to a
>> sub-directory.
>> > Should be trivial but cant think how w/o creating a temporary file
>> >
>> >
>> >
>>
>> Are you looking for smth like:
>>
>> find . -type f -exec grep -e "a certain string" {} \; -exec mv {} tmp \;
>>
>> HTH
>>
>> Heinrich
>>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author