Removal of 'c$' in batch

hi all!

I have written a batch file using sed and cat to read a ini file to get computer names specific to a site’s network. (basicly obtaining the computer names held in the ini)
this then sets them as variables and calls a seperate batch with the variables to update a dll on the machines on the network.
this bit is fine and working fine.

the problem comes when trying to use pstools to kill a service and such before copying the file, for the ini file that i am able to obtain the computer name from includes a ‘\c$’ at the end of the line.
when mapping a drive this works fine, but when using psservice you cannot have the c$ after the computer name.

My question is how do i remove all \c$ from a text file within a batch?

I have tried to use sed again to along the lines of;

cat file.bat | sed “s/\c$/ /” >file2.bat

but obviously this doesn’t work at all.

Any suggestions to how to progress would be greatly appreciated for at the moment:coffee:

hmm assuming you’re using a windoze implementation of sed ?

in Unix there are issues with special characters being interpreted by the shell (command line) rather than by the command itself… special characters are forced to be taken literally by “escaping” ie, preceding them with a \

so in unix you’d have to do
cat file.bat | sed “s/\c$/ /” >file2.bat
note the the extra 's escaping the \ and $ in the original string.

As I say, this would be the unix way, not sure how applicable it is on windows.

Alternatively, just open the file in your favourite editor and global replace :wink:
in vi you’d use :%s/\c$//g

Spaceboy i think i could kiss you!
the sed i am using is basicly the unix version adapted for windows (can provide a copy if you like:P) and with you superior syntax knowledge it now does exactly what i wanted it to do.

hehe glad it worked!

cheers for the offer, but I try and avoid sed at the best of times, let alone scripting in windows /shudder :wink:

No worries, i thaught as much… didn’t refuse the kiss tho!