【发布时间】:2013-09-14 10:53:23
【问题描述】:
我有一个目录中具有以下命名约定的文件列表:prefix_2chars_suffix
示例:currentfile_aa_belongsToprojectForDepcurrentfile_bb_belongsToprojectForDep 等
我想“提取前缀和后缀之间的 2 个字符。所以我想使用 sed。
我尝试了以下方法:
ls currentfile_* | sed 's/currentfile_\([..]\)_belongsToprojectForDep/\1/g'
我明白了:
sed: -e 表达式#1, char 44: 未知命令: `\'
但是当我这样做时:echo this is digit 7 in a number | sed 's/digit \([0-9]\)/\1/'
它有效,这意味着我的语法没有错误
我在这里做错了什么?
【问题讨论】:
标签: regex linux bash sed cygwin