Reputation: 2079
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
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
Reputation: 13765
Use continue
http://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-continue-in-bash-loop/
Upvotes: 4