我在目录中有以下文件:
f.txt
fi.txt
fil.txt
file.txt
filen.txt
filena.txt
filenam.txt
filename.txt
filenametoolong.txt
除了最后一个,我想移动所有。以下正则表达式适用于我的需求:^。{1,13} .txt
但是,使用带有“mv”的正则表达式
mv ^.{1,13}\.txt trashdir
结果
mv: cannot stat `^.1.txt': No such file or directory
mv: cannot stat `^.24.txt': No such file or directory
我检查并仔细检查了正则表达式语法,它似乎是有效的。我错过了什么?
答案 0 :(得分:2)
mv
命令不支持正则表达式。您可以将find
与-regex
选项一起使用:
find . -maxdepth 1 -type f -regex '\./.\{1,13\}' -exec mv {} /trashdir +