Only list Guid format files

Hi,

I'm trying to only list files and directories in Guid format, but when I execute this command it looks like I'm still getting all of the contents of the current directory.

Code:
find -E . -depth 1 -ls -regex '^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$'

I see directories like 9ac52398-7850-40ff-8b8c-62d2306d46f3 listed by I also see files like output.txt listed.

Is the regex not working?
 
Remove the -ls. You're telling it to show all files. The regexp comes after that. If you want the -ls add it to the end.
 
I had a feeling that would be the first answer :p

Unfortunately I already tried that, and it didn't work.

Moving the -ls to the end gives no ouput...
 
Testing here shows you need to add the leading path to the regex to match what find(1) displays, a ./ for this example. The parens aren't needed:
% find -E . -depth 1 -regex '^\./[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'

But that regex is pretty complicated. There is a character class for hex digits, [:xdigit:], that makes it clearer. And since those four-character terms in the filename are repeated three times, that can be reduced to a "match three of these".
% find -E . -depth 1 -regex '^\./[[:xdigit:]]{8}(-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}$'

Tested, seems to work.

SirDice is right about -ls, if needed, add it at the end.
 
Oh I see, I wasn't taking find's output into consideration... no wonder!

I was going to say, I checked my regexp with ls | grep and it worked fine...

Thanks for the tip wblock@ with the character class, really handy!
And thanks SirDice for your sound advice, I'm sorry that I hadn't posted by -ls and grep tests sooner.

Cheers!
 
Back
Top