Parameswar
Parameswar

Reputation: 2079

Skipping a line and reading another line in shell script while loop

i have a code which reads a file line by line using a while loop. Inside the while loop, i have certain conditions. Is there a way using which i can skip the current line and read the next line based upon the condition ? Let me be precise:

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**

Any help would be appreciated.

Upvotes: 5

Views: 20716

Answers (2)

Chaitanya
Chaitanya

Reputation: 46

How about:

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**

Upvotes: 2

Related Questions