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 and shell scripting languages 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-06-2008 12:20 AM
find and replace rakshit Shell Programming and Scripting 4 01-24-2008 03:52 AM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 01:05 PM
find and replace ram2s2001 Shell Programming and Scripting 2 12-05-2005 02:46 AM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 04:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-11-2008
cv_pan cv_pan is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 12
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
  #2 (permalink)  
Old 06-11-2008
mschwage mschwage is offline
Registered User
  
 

Join Date: Jul 2005
Location: Oak Park, IL
Posts: 102
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

  #3 (permalink)  
Old 06-18-2008
cv_pan cv_pan is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 12
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!
  #4 (permalink)  
Old 06-18-2008
cv_pan cv_pan is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 12
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?
  #5 (permalink)  
Old 06-18-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,345
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0