Please use ***[code][/code]
*** tags around your code and data, to preserve the original formatting and to improve readability. Do not
use quote tags, bolding, colors, "start/end" lines, or other creative techniques. Thanks.
As mentioned, if you use exit
, you'll stop the script. In this case you don't need to do anything special. The loop will simply continue until every line in the file is processed.
I'd write it slightly differently though:
while read -r line || [[ -n $line ]]; do
printf '%s\n\n' "$line"
if grep "Enable" "$serverfile" >>"$withkeywordfile" ; then
echo "$line not found" >>"$withoutkeywordfile"
The [[ -n $line ]]
addition is there in case the input file doesn't have a final newline
Finally, you should always take care to keep your code and data as separate as possible. Setting all of your filenames as variables at the top of the script is one recommended suggestion.
Scripting With Style