在循环中跳过一行并在shell脚本中读取另一行

时间:2012-04-13 11:23:49

标签: shell while-loop

我有一个使用while循环逐行读取文件的代码。在while循环中,我有一定的条件。有没有办法可以跳过当前行并根据条件读取下一行?让我准确一点:

while read Line
do
    //some sample conditions
    a=$Line
    if [ "a" == "b" ]
        //i want to go to the next line from this point. 
done < **inputfile**

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

答案 1 :(得分:2)

怎么样:

while read Line
do
    # some sample conditions
    a=$Line
    if [ "$a" == "$b" ] # I assume this is not "a" == "b"
        # i want to go to the next line from this point. 
        read Line
        a=$Line
done < **inputfile**
相关问题