I wanna convert some java files and replace the umlauts Ö,ä and ü as unicode.
Here's my sed line:
sed -i '{ /^(#|\*$)/!s/0xE4/0xE4/g;/#/!s/Ä/0xC4/g;/#/!s/ö/0xF6/g;/#/!s/Ö/0xD6/g;/#/!s/ü/0xFC/g;/#/!s/Ü/0xDC/g; }' 
scenario:
Before sed it looks like :
# comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
ÖÖÖÖÖÖÖÖÖ
// comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
 Text text text ÄÄÄÄÄÖÖÖÖÖ
/*
 * comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
 */
After it should looks like that :
 # comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
 0xD60xD60xD60xD60xD60xD60xD60xD60xD60xD60xD60xD6
// comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
 Text text text 0xC40xC40xC40xC40xC40xD60xD60xD60xD60xD6
/*
 * comment with umlauts ÄÄÄÄÄÄÖÖÖÖÖ
 */
Could开发者_JAVA百科 anyone help me with the matching? - I"ve got but it doesn't works right:
/^(#|\*$)/!
Posix sed
sed '\%^ *\(#\|//\|\*\|/\*\)%!{
 s/Ä/0xC4/g
 s/ö/0xF6/g
 s/Ö/0xD6/g
 s/ü/0xFC/g
 s/Ü/0xDC/g
}'
GNU sed
sed -r '\%^ *(#|//|\*|/\*)%!{
 s/Ä/0xC4/g
 s/ö/0xF6/g
 s/Ö/0xD6/g
 s/ü/0xFC/g
 s/Ü/0xDC/g
}'
Updated with ninjalj's comments. An actual ninja edit!
sed uses basic regular expressions, so you have to write ( as \( and | as \|.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论