首页 > 解决方案 > 从循环内部读取 ASCII 文件,每次迭代读取 shell 脚本中的一行

问题描述

我想在while-loop 中读取一个 ASCII 文件,每次迭代我想从文件的第二行开始读取每一行。经过大量搜索后,我想出了以下内容:

    a=1
    while [ $a -le 04 ]
    do
    while read p q r; do
    root -l macro.C\($r\) #the operation is dependent of the entries of the third column in the ASCII file
    done < ascii.txt
    a=`expr $a + 1`
    done

但是,这似乎不符合我的目的。首先,我想跳过第一行,但不知道该怎么做。此外,它的作用是为外部循环的每次迭代提供该列的所有条目while

有人可以帮我吗?

谢谢和问候, Saumyen

标签: shell

解决方案


推荐阅读