![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find and Replace | NycUnxer | UNIX for Dummies Questions & Answers | 4 | 03-05-2008 09:20 PM |
| find and replace | rakshit | Shell Programming and Scripting | 4 | 01-24-2008 12:52 AM |
| 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 11:46 PM |
| Find & Replace | gagansharma | Shell Programming and Scripting | 3 | 11-27-2001 01:17 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
Quote:
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
The -e option isn't necessary here, it's for combining multiple commands.
Quote:
Place the mv command after the loop. Regards |
|||
| Google The UNIX and Linux Forums |