bash – Skip printing on line matching regex pattern
How can I skip printing on the line that matches pattern. For remaining lines do the pront with the corresponding printf until a new line wathes another pattern.
printf '%s\n' "$@" \
| while IFS="" read -r vl; do
if [[ "$vl" =~ ^[[:space:]]*Wht:[[:space:]]*$ ]]; then
printf '%s%s%s\n' "${wht}" "$vl" "${rst}"
elif [[ "$vl" =~ ^[[:space:]]*Grn:[[:space:]]*$ ]]; then
printf '%s%s%s\n' "${grn}" "$vl" "${rst}"
elif [[ "$vl" =~ ^[[:space:]]*Blu:[[:space:]]*$ ]]; then
printf '%s%s%s\n' "${blu}" "$vl" "${rst}"
else
printf '%s%s%s\n' "${wht}" "$vl" "${rst}"
fi
done
Read more here: Source link
