Why is the "extra characters after command" displayed for the sed command line?

I gave the command line as shown below

Command:

sed '/dump 0 $2 $3 $4 $5/dump 1 $2 $3 $4 $5/g' base_file.properties 

error showing

sed: -e expression # 1, char 22: extra characters after command

when setting the "s" option as

  sed 's/dump 0 $2 $3 $4 $5/dump 1 $2 $3 $4 $5/g' base_file.properties 

the error is displayed as

sed: -e expression # 1, char 32: unknown option `s'

+6
source share
1 answer

Some of the variables seem to expand to values โ€‹โ€‹containing / . Use another delimiter that is not contained in any of the variables, e.g.

 sed ' s@dump 0 $2 $3 $4 $5@dump 1 $2 $3 $4 $5@g ' base_file.properties 

(Your first command is not a valid sed expression.)

+5
source

Source: https://habr.com/ru/post/950530/


All Articles