Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 100 多个文件的目录,我有一个列表,每个文件都有一个编号。我想像这样运行一个for循环
numPairs="21 57 93... etc" for filename in /directory/; do $filename [numPairs[1]] > newfilename done;
有没有办法(比如在 js 中,这就是我所熟悉的)调用与 for 循环中调用的文件名相对应的 numPairs 项?还是我会更好地创建另一个包含所有文件名的列表?
巴什就像:
numbers="21 57 93" while IFS=$'\t' read -r num file; do echo "num=$num file=$file" done < <(paste <(printf "%s\n" $numbers) <(printf "%s\n" /directory/*))