Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I escape single quotes with perl interpreter?

Tags:

bash

perl

How do I escape the single qoutes in my bash expression find . | xargs perl -pi -e 's/'conflicts' => '',//g'? I want to replace the string 'conflicts' => '', in my files?

like image 270
Micromega Avatar asked May 22 '13 19:05

Micromega


1 Answers

FatalError and gpojd have both given good solutions. I'll round this out with one other option:

find . | xargs perl -pi -e 's/\x27conflicts\x27 => \x27\x27,//g'

This works because in Perl, the s/.../.../ notation supports backslash-escapes. \x27 is a hexadecimal escape (' being U+0027).

like image 178
ruakh Avatar answered Nov 15 '22 13:11

ruakh