user3611574
user3611574

Reputation: 13

Remove " from a file using Perl script

I have a sample file like this

001|"Arab"|hjgjk
002|"HGJ"|dkflj

i need the output like

001|Arab|hjgjk
002|HGJ|dkflj

i have tried below code

perl -pi -e 's/\"//g' file1 > file2

Please help

Upvotes: 0

Views: 61

Answers (2)

user3611574
user3611574

Reputation: 13

We need to give something like

perl -p -e 's/"^""//g' file1 > file2 

if we are working on Windows, because "^" is the escape sequence for " in Windows.

Upvotes: 0

Andy Lester
Andy Lester

Reputation: 93735

If you are using the -i that means "in place", and so you don't need to redirect the output. Either do this:

perl -pi -e 's/\"//g' file1

or this:

perl -p -e 's/\"//g' file1 > file2

But don't combine -i and redirection.

Upvotes: 1

Related Questions