5

我有一个代码,它使用 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**

任何帮助,将不胜感激。

4

2 回答 2

4

使用continue http://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-continue-in-bash-loop/

于 2012-04-13T11:28:57.160 回答
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**
于 2012-04-13T12:05:06.327 回答