Sed command failing with bad flag in script

Himanshu

I am trying to replace submodules from .gitmodules repo with repo-name using below script. This script is created by other team. Is there a way I can satisfy the output of before command to satisfy the sed.

echo "submodule.repo.path" | sed -nE 's/^submodule\.src/(.*)\.path$/\1/pi'

Above command failing with an error:- sed: 1: "s/^submodule\.src/(.*)\ ...": bad flag in substitute command: '\'

Amadan

Correct to:

echo "submodule.src/repo.path" | sed -nE 's/^submodule\.src\/(.*)\.path$/\1/pi'

You failed to escape a slash in your search, which caused your replacement to be (.*)\.path$ and your flags \1/pi; sed is complaining these are not legal flags for s// command.

(Also, the pattern did not match the test string, so I changed the test string to something that does.)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

sed command with -i option failing on Mac, but works on Linux

Sed error: bad flag in substitute command: 'U'

Sed command in perl script

Jenkins pipeline failing for sed command

Bad substitution error when passing decremented variable to "sed" command

What is to be done to fix Git log command failing from a Bitrise script

Sed unterminated 's command in script

Using sed output in another script or command

"bad flag in substitute command: '{" while replacing a string with sed from one file to another file

Execute sed command in a bash script

Bash script using mysql command with variables failing

Run sed command in perl script

Exec command failing on some PCs in psake script to OpenCover

expect command in bash script failing

Getting bad flag in substitute command '/' for sed replacement

sed command works with e flag but not with E

sed in bash script: unknown command: `''`

sed s command & e flag: `echo '$-' | sed 's/-//e'` gives: `sh: $: command not found`

bash: bad flag in substitute command with escaped slashes

Sed command in Windows batch script

SFTP Manual command succeed but script is failing at 1 or 2%

sed throws 'bad flag in substitute command' but works fine in package.json

sed command: bad flag in substitute command: '-'

How to fix Bad File descriptor in a Sed Command in unix

What does this sed command do in this script?

Is sed allowed to create a file if w command or flag is never executed?

How to pass a variable to a sed command in a csh script?

sed command in Jenkins script

sed shell command into Python script