Solved

Perl command line search replace word with apostrophe in it

Posted on 2011-02-15
1
878 Views
Last Modified: 2012-05-11
I trying to search and replace using Perl on the command line, not sure how to escape the apostrophe in the command.

ie. Replace Latest's -> Latest
perl -pi -e 's/Latest''s/Latest/g' *.pl <- doesn't work


0
Comment
Question by:freshgrill
1 Comment
 
LVL 1

Accepted Solution

by:
Levant earned 500 total points
ID: 34897232
Here is the line that worked for me:

perl -pi.bak -e "s/Latest\'s/Latest/g;" 1.pl

I think you should use \' (backslash ') to escape the apostrophe.

Sincerely,
Boris
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question