I believe I am calling exit in a subshell that causes my program to continue:
#!/bin/bash
grep str file | while read line
do
exit 0
done
echo "String that should not really show up!"
Any idea how I can get out of the main program?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can trivially restructure to avoid the subshell — or, rather, to run the
grepinside the subshell rather than thewhile readloop.Note that
<()is bash-only syntax, and does not work with/bin/sh.