|
|
|
how to remove \ from variable
|
Original Message
|
Name: newbie (by newtechie)
Date: September 18, 2007 at 15:27:06 Pacific
Subject: how to remove \ from variableOS: windows server 2003CPU/Ram: intel p4Model/Manufacturer: dell |
Comment: Hi guys I'm very new to batch programming and am unable to find this: i have managed to get a file location from a text file into a variable. However the file name is in the format c\:\\program files\\locationofprogram\\program. I want to get this such that i can remove the extra '\' characters from this path, ie read c:\program files\locationofprogram\program. How do i do this in batch?? please help i'm going nuts trying to figure this one out
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: newbie (by newtechie)
Date: September 18, 2007 at 17:47:12 Pacific
|
Reply: (edit)thanks for the response - works great but now i'm wondering, if there is a way to automate this? ie. location could be longer/shorter with a different hierarchical structure...so hardcoding the formatting is kind of risky - is there a way to remove '\' with some kind of loop that compares the string charcter by character and concatenates? any help is appreciated - thanks
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: ghostdog
Date: September 18, 2007 at 19:33:44 Pacific
|
Reply: (edit)though you can spend your time filtering out the extra slashes, my opinion is to tackle the problem at the source. Are you able to NOT generate file paths like that to the text file?
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: newbie (by newtechie)
Date: September 19, 2007 at 12:49:20 Pacific
|
Reply: (edit)unfortunately - no its written to in a read-only file by sepereate module.. but thanks for the responses ~newtechie
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: n1988
Date: October 12, 2007 at 08:36:56 Pacific
|
Reply: (edit)I want to remove '$' from a $ variable. I create a script, a.sh as below: #!/usr/bin/ksh a=`echo $1 | cut -d"\$" -f1` b=`echo $1 | cut -d"\$" -f2` echo $a$b However, this script does not work as I expect For example when I run the script as below: a.sh abc$def. The script displays 'abcabc' instead of 'abcdef'
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: Mechanix2Go
Date: October 13, 2007 at 01:30:42 Pacific
|
Reply: (edit)Beside the obvious that shell scripts have little or nothing in common with winders.
===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: ghostdog
Date: October 13, 2007 at 01:49:13 Pacific
|
Reply: (edit)who knows he might be using cygwin or SFU... @OP, $ is sensitive to the shell, when you pass the variable, escape it like this abc\$def. should do the trick.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|