我没有充分解释这个问题所以它被误解为重复。
我想每次读取CSV文件中的N行并执行操作行(名称)的脚本。如何将N行作为参数发送到另一个脚本并并行执行?
该文件是带有+400000行的CSV,如下所示:
nombre,ape_paterno,ape_materno
ALFREDO,AGUILAR,AGUILAR
ANGEL,AGUILAR,AGUILAR
CARLOS,AGUILAR,AGUILAR
DANIEL,AGUILAR,AGUILAR
EDUARDO,AGUILAR,AGUILAR
ELIZABETH,AGUILAR,AGUILAR
FERNANDO ,AGUILAR,AGUILAR
FRANCISCA,AGUILAR,AGUILAR
FRANCISCO ,AGUILAR,AGUILAR
FRANCISCO JAVIER,AGUILAR,AGUILAR
...
我想要这样的事情:
{
read
while IFS="," read $N lines
do
sh ${DIR}/Downloader.sh $N-Lines-as-argument &
done } < "$input"
wait
我尝试了here的答案,但我的结果为空。
答案 0 :(得分:1)
您可以在BASH中使用此脚本:
#!/bin/bash
n=50 # number of line to read every time
while read -r && arr=("$REPLY"); do
# read n-1 lines using a for loop
for ((i=1; i<n; i++)); do
read -r && arr+=("$REPLY")
done
# call your script using 50 element array as argument
bash ${DIR}/Downloader.sh "${arr[@]}" &
done < file