Tag Info

New answers tagged

2

In an xterm you can get the current color RGB color codes reported by altering a color change escape to a query. Use the ESC ] Ps m - but add a ? question mark. From the docs: If a "?" is given rather than a name or RGB specification, xterm replies with a control sequence of the same form which can be used to set the corresponding dynamic color. Because ...


1

You need to escape the [ and \ characters with a backslash: printf '%s' "foo.bar\033[00m" | sed 's/\.bar\\033\[00m//' Alternatively, if you want to remove everything after the dot character in the string: printf "foo.bar\033[00m" | sed 's/\..*//'


3

If you want in the output just foo then printf '%s' 'foo.bar\033[00m' | sed 's/\.bar\\033\[00m//' Notice that both \ and [ has to escaped by another \. Additionally I've added '%s' to printf to print the input characters as literal string, otherwise \033[ could be interpreted as escape code followed by ANSI colour. After question edit: If your file ...


0

I'm not sure if you replace \n with ^M will be fix your issue. But you can use tr command to replace it with single back-slash: $ printf "%s\n" 'a\\b'| tr -s '\\' '\\' a\b


1

If you want to replace \\ with \ with sed you just need to escape each of \, so for example: $ printf "%s\n" 'a\\b' a\\b $ printf "%s\n" 'a\\b' | sed 's/\\\\/\\/g' a\b But, frankly speaking it seems that in your case it would be better to correct mysql command, so I think this question is better suited to stackoverflow.com.



Top 50 recent answers are included