Recently I tried passing a bash variable to perl command in bash script, it didn’t end well.
Troy Engel from http://tacticalvim.wordpress.com/ was nice enough to point out the issue:
use sed instead of perl for what you need; it’s simpler, faster and uses the bash variables easily.
I set up a test script /home/someuser/test.sh to show:
. . . → Read More: passing bash variable to perl command in bash script
I spent forever trying to figure out how to unwrap an apache access_log that was splitting requests between two lines. I finally found the answer!
Create a perl script called unwrap.pl and run the script like this:
# perl unwrap.pl access_log > accesslog2 #!/bin/env perl use strict; my $sentinel = 0; my $previous_line; my $result . . . → Read More: linux unwrap text file
perl replace text in multiple files
perl -pi -e ‘s~OLDTEXT~NEWTEXT~g’ /path/to/filenames/*
Alternative (to avoid escaping slashes):
perl -pi -e ‘s|w/|with|g’
here’s how to replace text in a file with perl:
perl -pi -e ‘s~OLDTEXT~NEWTEXT~g’ /path/to/filename