Search Results

Search: Posts Made By: lehaste
11,748
Posted By lehaste
I'm using Red Hat, 2.16.0. Here is the line of...
I'm using Red Hat, 2.16.0. Here is the line of perl code I'm using to write the sed command to the shell script:
print {$sh} "set expr=`echo $temp | sed 's/[][]/\\&\g'`\n";
11,748
Posted By lehaste
I tried sed s'/[][]/\\&/g' but it replaced the...
I tried sed s'/[][]/\\&/g' but it replaced the square brackets with &. Any suggestions?

Note: I'm writing this sed command to a file using perl - maybe I need to add more backslashes. Will try now.
11,748
Posted By lehaste
Thanks mirni!
Thanks mirni!
11,748
Posted By lehaste
Works great! Can one of you explain what is...
Works great! Can one of you explain what is happening with the regular expression?
11,748
Posted By lehaste
Adding a backslash in front of square brackets with sed
I'm trying to convert this line:
[some text]

to

\[some text\] with sed.

This is what I have so far:
sed -e 's/\[\([^]]*\)\]/\\\\\[\1\\\\\]/'

but this still gives me [some text].
...
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 02:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy