0

I have this as variable

set var=1920 x 1080p / 23.976 fps /16:9 / High Profile 4.1

and i will replace with sed

sed -e "s/1920/%var%/" movie.txt > movie2.txt.nfo

error output is

ed: -e expression #1, char 30: unknown option to `s'

I do not understand what's wrong

Regards

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • Try to change the delimiter, something like: `sed -e "s-1920-%var%-"` – Maroun Nov 12 '17 at 09:04
  • big thx, working. –  Nov 12 '17 at 09:06
  • 2
    Does this answer your question? [How to pass a variable containing slashes to sed](https://stackoverflow.com/questions/27787536/how-to-pass-a-variable-containing-slashes-to-sed) – tripleee Sep 25 '20 at 09:24

1 Answers1

2

The problem is with slashes. Your final command will have many slashes coming from the variable itself, which will be confused with the / delimiter you provided in the sed command itself.

Luckily, sed can have any char as the delimiter. Change to something like:

 sed -e "s-1920-%var%-"

Now, - won't be confused with / (from the variable).

Maroun
  • 94,125
  • 30
  • 188
  • 241