Handle special characters

0

I am trying to return the CURL with SED, but as the information I get but sometimes has the character / causes an error in the SED syntax.

TOKEN=$(curl --silent $URL | awk -F '"' '/content/ {print $2}')
echo $TOKEN

2CTVaTm46Uoregv0VcU2QPd15B3G / OpNgX7IAvL9cNs =

sed -e "s/@TOKEN/$TOKEN/" $JSON_FILE > /tmp/$NAME.json

sed: -e expression # 1, char 39: unknown option to 's'

How can I specify for SED that when there is / in the replacement variable, it should not be interpreted as a command?

    
asked by anonymous 05.04.2018 / 16:08

1 answer

0

In sed, pass the backslash before the normal bar.

Ex: sed '/channelType/,/\/channelType/!d' file.log

In the above command I'm picking up a portion of the log that goes from " channelType " to " /channelType" ."     

15.06.2018 / 15:31