我的目录中有 4000 个具有唯一文件名的文本文件。
是否有任何Linux 命令可以仅连接 1-100 个文件。
cat 1.txt ... 100.txt > 1.100.txt
cat 101.txt ... 200.txt > 2.200.txt
.......
.......
cat 3901.txt ... 4000.txt > 40.4000.txt
Run Code Online (Sandbox Code Playgroud)
请提出建议。
和zsh
:
files=( *(N.n) ) i=0
while (( $#files )) {
() {cat -- $@ > $((++i)).$@[-1]} $files[1,100]
files[1,100]=()
}
Run Code Online (Sandbox Code Playgroud)
globn
限定符按数字对文件名进行排序,您可以将其更改为按Om
修改时间从最旧到最新的顺序。O
m