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"

沒有留言:

張貼留言

[ Py DS ] Ch1 - IPython: Beyond Normal Python

Source From  Here   Keyboard Shortcuts in the IPython Shell   If you spend any amount of time on the computer, you’ve probably found a u...