LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-07-2006, 03:09 AM   #1
Erhnam
Member
 
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, 03:24 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,276

Rep: Reputation: 170Reputation: 170
's/C:\\Log/C:\\Log.v2/'

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

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

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

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


Reply


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 12:45 PM
How to search and replace a text using grep DediPlace Linux - General 2 05-29-2005 06:47 PM
How to "Search & Replace" in html files using Perl? rebel Red Hat 8 04-09-2005 12:58 PM
replace text in files and directories rincewind Linux - Software 4 10-27-2004 11:29 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM


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

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