Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Deleting files with two identical parts in filename



2008/7/8 Jens Kubieziel <maillist@xxxxxxxxxxxx>:
> Hi,
>
> in a directory there are some files:
> # ls
> abc.bar+bar abc.bar+foo abc.foo+bar abc.foo+baz abc.foo+foo
>
> I want to delete all files which have the same string before and after
> the '+' (abc.bar+bar and abc.foo+foo). Is there a way with zsh to do
> just 'rm $SOME_MAGIC_COMMAND', which does the job?

rm *(e:'[[ $REPLY = abc.(#b)(???)+(???) ]] && [[ $match[1] = $match[2] ]]':)

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author