The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find and Replace NycUnxer UNIX for Dummies Questions & Answers 4 03-05-2008 08:20 PM
find and replace rakshit Shell Programming and Scripting 4 01-23-2008 11:52 PM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 09:05 AM
find and replace ram2s2001 Shell Programming and Scripting 2 12-04-2005 10:46 PM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 12:17 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2008
Registered User
 

Join Date: Jun 2008
Posts: 3
To find and replace paths consisting \

Hi all,
I am new to unix and wanted to replace the string consisting \ with nothing.

I tried the following but did not help.

for y in `ls DIV*`;
do
sed s/C:\\Project\\AML\\bin//g $y > temp
mv temp $y
done

I actually want to remove any occurance of C:\Project\ABC\bin in the files.

Thanks & Regards
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-11-2008
Registered User
 

Join Date: Jul 2005
Location: Chicago, IL
Posts: 93
Quote:
Originally Posted by cv_pan View Post
I actually want to remove any occurance of C:\Project\ABC\bin in the files.
Got it.

Quote:
Originally Posted by cv_pan View Post
Hi all,
I am new to unix and wanted to replace the string consisting \ with nothing.
No you don't...

Anyway, all wisecracks aside, you're actually pretty close. Here's your solution:

Code:
for y in `ls DIV*`
do
       temp=`echo $y | sed -e 's/C:\\Project\\AML\\bin//g'`
       mv $temp $y
done
Reply With Quote
  #3 (permalink)  
Old 06-18-2008
Registered User
 

Join Date: Jun 2008
Posts: 3
mschwage

Thanks a lot!! works as expected

however, could you please elaborate on -e option..

-e Script
"Uses the Script variable as the editing script. If you are using just one -e flag and no -f flag, the -e flag can be omitted."

I do not understand it competely.. Thanks in advance!
Reply With Quote
  #4 (permalink)  
Old 06-18-2008
Registered User
 

Join Date: Jun 2008
Posts: 3
for y in `ls DIV*`
do
sed -e 's/C:\\Project\\AML\\bin//g' $y > temp
mv temp $y
done

I had to do this instead as I kept getting the error sayng both $temp & $y are identical.. is something wrong?
Reply With Quote
  #5 (permalink)  
Old 06-18-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,615
Quote:
Originally Posted by cv_pan View Post
however, could you please elaborate on -e option..
The -e option isn't necessary here, it's for combining multiple commands.

Quote:
Originally Posted by cv_pan View Post
I had to do this instead as I kept getting the error sayng both $temp & $y are identical.. is something wrong?

Place the mv command after the loop.

Regards
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0