# Only list Guid format files



## davidkazuhiro (Oct 16, 2012)

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.


```
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?


----------



## SirDice (Oct 16, 2012)

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.


----------



## davidkazuhiro (Oct 16, 2012)

I had a feeling that would be the first answer 

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

Moving the -ls to the end gives no ouput...


----------



## SirDice (Oct 16, 2012)

davidkazuhiro said:
			
		

> Moving the -ls to the end gives no ouput...


Then your regexp isn't correct.


----------



## wblock@ (Oct 16, 2012)

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.


----------



## davidkazuhiro (Oct 18, 2012)

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!


----------

