This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Portable Cygwin: replacing drivename in a text file


Andrew DeFaria sent the following at Thursday, November 25, 2010 10:15 AM
>  On 11/25/2010 09:35 AM, Alexandre Bezroutchko wrote:
>>> you can use a different separator in the sed command.
>>> You can use the following line
>>>
>>>   echo 123 | sed "s%2%${HOME}%g"
>>
>> Right, this will work in most cases. But will fail if $HOME happens to
>> contains % sign.
>> The version I have suggested in the previous post is more robust.
>
>How often does that happen?

Use a character that is either or highly unlikely or forbidden to be in a file name.

Like < or >.

echo 123 | sed "s>2>@$HOME@>g


- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]