How do I do something like this?
"input" | \
if
grep -E 'phone_and_fax":"Phone: .* Fax:'
then
sed 's/phone_and_fax":"Phone:/|/g' | \
sed 's/ Fax:/|/g' | \
sed 's/original_license_date":"Original License Date:/|/g'
elif
grep 'phone_and_fax":"Phone: '
then
sed 's/phone_and_fax":"Phone:/|/g' | \
sed 's/original_license_date":"Original License Date:/||/g'
elif
grep ' Fax:'
then
sed 's/phone_and_fax":"Phone:/||/g' | \
sed 's/ Fax:/|/g' | \
sed 's/original_license_date":"Original License Date:/|/g'
else
sed 's/phone_and_fax":"Phone:/||/g' | \
sed 's/original_license_date":"Original License Date:/|/g'
fi | \
"continue script"
The point of what is being replaced or what is being looked for doesn't really matter. What I am trying to do is use some piping to handle some text, but if it runs across a certain pattern using grep with regex, then it needs to change what it will replace with that particular instance. But the grep should not change the output of the piping.
grepprobably isn't needed at all. Ifs/is/IS/gdoesn't match the stringis, the input is passed through unchanged, so you don't need to check ifisis present first.