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

循环时跳过shell脚本中的一行并读取另一行,shell,while-loop,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** 读取行时 做 //一

我有一个使用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**
读取行时
做
//一些样本条件
a=美元行
如果[“a”==“b”]
//我想从这一点转到下一行。
完成<**输入文件**

任何帮助都将不胜感激

使用
继续

如何:

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**
读取行时
做
#一些样本条件
a=美元行
如果[“$a”=“$b”]#我假设这不是“a”=“b”
#我想从这一点转到下一行。
读线
a=美元行
完成<**输入文件**

if条件可能是任何情况。我想要的是,根据条件,文件读取应该从下一行开始,然后立即执行。您提供的脚本将读取下一行,但它将只反映在条件之后的行中。我想要的是,根据条件,应该读取下一行,并且操作应该从头开始。如果我没有弄错您的评论,scibuff的答案就是您要找的。请你花点时间接受它或评论一下为什么这不是你想要的答案?谢谢大家!很抱歉迟了回复!你的解决方案奏效了!