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"

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...