Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-07-2006, 04:09 AM   #1
Registered: Jan 2005
Posts: 54

Rep: Reputation: 15
Perl: Search and replace directories within text files

Is it possible to search and replace directory locations within files using perl? I tried to do it with:

perl -pi.bak -e "s/C:\Log/C:\Log.v2/" test.txt

Where old location = C:\Log
Where new location = C:\Log.v2

The command above does not work.. Anyone can help me to sort this out? Thanks!
Old 03-07-2006, 04:24 AM   #2
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,421

Rep: Reputation: 200Reputation: 200Reputation: 200

\L sets all following chars to lower case up to an \E

print "\LHELLO THE\ERE\n";
hello theRE
Old 03-07-2006, 05:07 AM   #3
Registered: Jan 2005
Posts: 54

Original Poster
Rep: Reputation: 15
Thanks! Works!!

Last edited by Erhnam; 03-07-2006 at 05:11 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Regexp search-n-replace jpbarto Programming 2 06-16-2005 01:45 PM
How to search and replace a text using grep DediPlace Linux - General 2 05-29-2005 07:47 PM
How to "Search & Replace" in html files using Perl? rebel Red Hat 8 04-09-2005 01:58 PM
replace text in files and directories rincewind Linux - Software 4 10-27-2004 12:29 PM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 02:04 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration