Shell 如何在终端中使用范围触摸多个文件
我使用zsh。我想触摸0023.rb0024.rb。。。。0040.rb 是否有更好的方式使用终端中的范围来触摸文件Shell 如何在终端中使用范围触摸多个文件,shell,terminal,zsh,Shell,Terminal,Zsh,我使用zsh。我想触摸0023.rb0024.rb。。。。0040.rb 是否有更好的方式使用终端中的范围来触摸文件 # something like this $touch (0023..0040).rb 您希望,然后通过管道将其输出到: 您可以使用设置数字格式。对于最小4位0填充数字,请使用%04.f: seq -f %04.f 99 101|xargs -Inumber touch number.rb 在zsh下测试: kent$ touch {0010..0015}.foo
# something like this
$touch (0023..0040).rb
您希望,然后通过管道将其输出到:
您可以使用设置数字格式。对于最小4位0填充数字,请使用%04.f
:
seq -f %04.f 99 101|xargs -Inumber touch number.rb
在zsh下测试:
kent$ touch {0010..0015}.foo
kent$ l
total 0
-rw-r--r-- 1 kent kent 0 May 15 16:20 0010.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0011.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0012.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0013.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0014.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0015.foo
这是一个关于shell脚本的问题。关闭似乎过于热情。
kent$ touch {0010..0015}.foo
kent$ l
total 0
-rw-r--r-- 1 kent kent 0 May 15 16:20 0010.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0011.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0012.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0013.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0014.foo
-rw-r--r-- 1 kent kent 0 May 15 16:20 0015.foo