TonyStark
TonyStark

Reputation: 379

bash sed: -e expression #1, char 7: unterminated `s' command

Getting sed: -e expression #1, char 7: unterminated `s' command in bash script

Here is snippet:

que=`cat temp | grep -o -P '(?<=uid").*(?=text)' | sed -e 's/\\/ /g' | sed -e 's/["]//g' | cut -d ":" -f3 | cut -d "," -f1`

I searched some other answers on here but none of helped.

Upvotes: 3

Views: 2100

Answers (2)

Cyrus
Cyrus

Reputation: 88573

Switch from backticks to $(your command).

Upvotes: 3

Andrea Corbellini
Andrea Corbellini

Reputation: 17751

The problem is this:

sed -e 's/\\/ /g'

Because it's inside backticks, the \\ is being replaced with \. You need to double-escape it:

sed -e 's/\\\\/ /g'

Upvotes: 3

Related Questions