栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在find命令中使用正则表达式?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在find命令中使用正则表达式?

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

请注意,

.*/
由于
find
与整个路径匹配,因此需要在开头指定。

例:

susam@nifty:~/so$ find . -name "*.jpg"./foo-111.jpg./test/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg./81397018-b84a-11e0-9d2a-001b77dc0bed.jpgsusam@nifty:~/so$ susam@nifty:~/so$ find . -regextype sed -regex ".*/[a-f0-9-]{36}.jpg"./test/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg./81397018-b84a-11e0-9d2a-001b77dc0bed.jpg

我的find版本:

$ find --versionfind (GNU findutils) 4.4.2Copyright (C) 2007 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Written by Eric B. Decker, James Youngman, and Kevin Dalley.Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3bFeatures enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0) susam@nifty:~/so$ susam@nifty:~/so$ find . -regextype foo -regex ".*/[a-f0-9-]{36}.jpg"find: Unknown regular expression type `foo'; valid types are `findutils-default', `awk', `egrep', `ed', `emacs', `gnu-awk', `grep', `posix-awk', `posix-basic', `posix-egrep', `posix-extended', `posix-minimal-basic', `sed'.


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/383293.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号