【发布时间】:2017-12-24 06:27:35
【问题描述】:
我在一个目录中有*.new 文件的列表。这些文件的名称中包含 D1 将被替换为 D2 并且还必须将扩展名从 .new 删除为空
hello_world_D1_122.txt.new -------> hello_world_D2_122.txt
我尝试的是
ls -slt | grep -iE "*.new$" | awk -F " " '{print $10}' | xargs -I {} mv {} "echo {} | sed -e 's/.D1./.D2./g ; s/.new//g'"
此命令未产生所需的输出。上述命令的输出是
mv: rename hello_world_D1_122.txt.new to echo hello_world_D1_122.txt.new | sed -e 's/D1/D2/g ; s/.new//g': No such file or directory
【问题讨论】:
-
它有什么作用?提供问题的示例输出。
-
此命令将所有文件名转换为所需的文件名。例如:hello_world_D1_122.txt.new -------> hello_world_D2_122.txt
-
嘿!好的。我的意思是你当前的命令是做什么的?
-
您不会在控制台上看到任何内容,但是一旦处理了命令,就可以看到结果
-
我的命令给了我这个输出。 mv: 将 hello_world_D1_122.txt.new 重命名为 echo hello_world_D1_122.txt.new | sed -e 's/D1/D2/g ; s/.new//g': 没有这样的文件或目录