I'm trying to prepare my output for a grep expression, but when I try to modify the data to get it in the format I want I'm having issues getting it the way I want.
I'm using the following command to get a list of IP addresses that I need.
PRIV_IP=$(aws ec2 describe-instances \
--region "${REGION}" \
--output text \
--query 'Reservations[].Instances[].[PrivateIpAddress]' \
--filters Name=tag:TagA,Values="${TagAData}" \
Name=tag:TagB,Values="HOME" \
Name=tag:TagC,Values="MAIN" | sed 's/\./-/g' | sed 's/ /\\|/g')
This is the output of the command; it ignores the last sed statement.
echo $PRIV_IP
1-2-3-4 5-6-7-8 9-10-11-12
If I perform the sed manually it works as intended.
echo $PRIV_IP | sed 's/ /\\|/g'
1-2-3-4\|5-6-7-8\|9-10-11-12
Can someone provide some input on what I'm doing incorrectly?