H
Hans Deragon
Greetings.
I want to parse a file and replace a string with another, in my
example, replace @sysconfdir@ with /etc. The command:
perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
....and off course, the error (else I would not be writing here ):
Bareword found where operator expected at -e line 1, near
"s/\@sysconfdir\@/\Q/etc"
Unquoted string "tc" may clash with future reserved word at -e line 1.
Backslash found where operator expected at -e line 1, near "tc\"
syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
Execution of -e aborted due to compilation errors.
Anybody would care to explain why \Q does not work here, and what I
can do to fix it? I would like a one liner solution. Manually
backquoting / ("\/") does not work either.
If / in /etc is removed, it works as expected. / is simply not
quoted.
Best regards,
Hans Deragon
I want to parse a file and replace a string with another, in my
example, replace @sysconfdir@ with /etc. The command:
perl -wp -e "s/\@sysconfdir\@/\Q/etc\E/;" <file>
....and off course, the error (else I would not be writing here ):
Bareword found where operator expected at -e line 1, near
"s/\@sysconfdir\@/\Q/etc"
Unquoted string "tc" may clash with future reserved word at -e line 1.
Backslash found where operator expected at -e line 1, near "tc\"
syntax error at -e line 1, near "s/\@sysconfdir\@/\Q/etc"
Execution of -e aborted due to compilation errors.
Anybody would care to explain why \Q does not work here, and what I
can do to fix it? I would like a one liner solution. Manually
backquoting / ("\/") does not work either.
If / in /etc is removed, it works as expected. / is simply not
quoted.
Best regards,
Hans Deragon