Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: [Class Assignment] Regex and Output Files

by Don Coyote (Hermit)
on Feb 21, 2015 at 14:05 UTC ( [id://1117419]=note: print w/replies, xml ) Need Help??


in reply to Re^3: [Class Assignment] Regex and Output Files
in thread [Class Assignment] Regex and Output Files

Digital transcripts regarding the plight of a certain hammer wielding Aasgardian in this matter are also deemed of historical interest.

A substitution of a word in a file can be conducted from the command line. Optional backup can be output with a suffix of your choosing, placed after the -i flag.

Easy as

%> perl -pi -e "s/\bnew\b/old/ig;" .\newfile.txt

for a backup copy, place in a preheated oven

%> perl -pi.bak -e "s/\bnew\b/old/ig;" .\newfile.txt

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1117419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found