gran_profaci
gran_profaci

Reputation: 8473

replace strings with double quotes in a text file

I'm using the following command:

perl -pi -w -e 's/EmployeeDataModel/EmployeeData/g;' *.java 

This changes stuff like:

class EmployeeDataModel to class EmployeeData

However, when taking stuff like:

class="EmployeeDataModel" 

It doesn't seem to do anything.

Is there any solution against this?

Upvotes: 0

Views: 184

Answers (2)

Jerska
Jerska

Reputation: 12042

Are you actually sure ? Here is my first file :

$ cat perl_test
class EmployeeDataModel
class="EmployeeDataModel"

Now with your perl replacement :

$ cat perl_test | perl -pi -w -e 's/EmployeeDataModel/Test/g'
class Test
class="Test"

You must have done something wrong, maybe a typo in your string content, or something like that.

Upvotes: 2

captcha
captcha

Reputation: 3756

Code for GNU :

$echo class="EmployeeDataModel" |sed s/EmployeeDataModel/EmployeeData/g
class="EmployeeData"

And also works:

$echo class="EmployeeDataModel" |perl -pi -w -e s/EmployeeDataModel/EmployeeData/g;
class="EmployeeData"

Upvotes: 3

Related Questions