Bash - 使用变量作为范围的上限

问题描述 投票:0回答:0

我正在尝试编写一个脚本,该脚本从 cli 获取参数并将该数字用作创建多个文件的范围内的上限。

num_files=$1
time parallel -N 10 'cat source.txt | tee copy{1}.txt copy{2}.txt copy{3}.txt copy{4}.txt copy{5}.txt copy{6}.txt copy{7}.txt copy{8}.txt copy{9}.txt copy{10}.txt' ::: {1..$numfiles}

我已经尝试了所有我能想到的引用类型,但奇怪的是,我得到的唯一输出是一个名为

copy{1..200}.txt
的文件(如果我通过 200)。所以我传入的号码被正确接收,只是没有像我预期的那样工作。

这可能吗?

bash shell tee
© www.soinside.com 2019 - 2024. All rights reserved.