【发布时间】:2013-12-18 13:26:33
【问题描述】:
我有一堆这样命名的文件:
text 01 (blabla) other text
text 02 (whatever) other text
.
.
text 025 (etc) other tex
some text 1 (20031020) other text
some text 2 (20031022) other text
.
.
some text 10 (20031025) other text
some new text 01 other text
.
.
.
some new text 200 other text
我想从文件名中只提取第一个数字之前的单词,所以从上面的例子中我想获得:
text
some text
some new text
我想这样做是为了根据文件名移动所属文件夹中的每个文件(或者如果文件夹不存在,则创建该文件夹)。
我想用 bash 做到这一点,我知道它可以使用正则表达式来完成,但我不知道如何,我只看到了字段由已知字符分隔的示例,而在这种情况下限制是后跟任意数字的空格。
【问题讨论】:
-
您只想要您的示例所示的唯一字符串吗?