2018年4月18日 星期三

[Linux 常見問題] How to use regex with find command?

Source From Here 
Question 
I have some images named with generated uuid1 string. For example 81397018-b84a-11e0-9d2a-001b77dc0bed.jpg. I want to find out all these images using "find" command: 
# find . -regex "[a-f0-9\-]\{36\}\.jpg".

But it doesn't work. Something wrong with the regex? Could someone help me with this? 

How-To 
Try below command: 
// -regextype type: Changes the regular expression syntax understood by -regex and -iregex tests which occur later on the command line.
// -regex pattern: File name matches regular expression pattern. This is a match on the whole path, not a search.

# find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg"

沒有留言:

張貼留言

[ Python 常見問題 ] Get all object attributes in Python?

Source From  Here   Question   Is there a way to  get all attributes/methods/fields/etc. of an object in Python ?  vars()  is close to what ...