Ladies and Gentlemen,
I am confused.
WTF is going on here? Why do the same sed versions on different machines perform differently? Locales you say... Right.
I tried without UTF-8 now, because my box indeed is UTF-8 only.
Code: Select all
tbart@black_knight ~ $ LC_ALL=en_US.ISO-8859-1 LANG=en_US.ISO-8859-1 echo -e "\x31\x32\x33\xaa\x31\x32\x33" | sed -e 's#3.*#SUBST#'
12SUBST<unprintable char>123
We see mixed problems here I guess.
This:
jw5801 wrote:I'm using GNU sed 4.1.5, and as you can see, the original command produces the desired output:
Code: Select all
jw@Andornor ~ $ echo -e "\x31\x32\x33\xaa\x31\x32\x33" | sed -e 's#3.*#SUBST#'
12SUBST
might be because your terminal emulator is not capable of printing the unprintable character. You could try to rule that out..
This might also explain why the division sign example does not work for you. Your terminal does not seem to be UTF-8 capable which additionally seems to be a different thing than the locale itself.
I am mostly with truc now. I have the same results as he has, same version of sed.
jw5801:
Did you try
?
Me (and truc) only get
Code: Select all
sed: -e expression #1, char 22: Invalid collation character
so this does not seem to be the way to go.
Just for further clarification:
I am operating on binary files (DV-DIF in AVI, that is) so I really have to match \x00-\xFF, so character classes like [:print:] (or the negation of it) won't do.
Precisely I want to match
\x60 <any four by tes> \x61 <any four by tes> \x62 \xFF \x1F \xFF \xFF \x63 <any four by tes>
and substitute the \x62 part with something different.
(The initiated might note: I am trying to change the DV-DIF's record date; I could (and that's the way I do it now) only search and replace the \x62 part, but I want to match as much as possible so I don't accidentally change the same sequence in actual video data; I know DV-DIF has a specified fixed structure and it screams for a C program but hey, where's the fun? No, seriously, I already have windoze dll code for doing this, but it's not my code, it's a dozen files and I am simply not that much into C programming as I am into bash scripting ;->)
I will take a look at bbe, but I'd like to use standard tools... Also because this might have to be portable to win32/cygwin which means any additional application is a hurdle more to take.
Where are the sed masters out there? (I initially thought I am one...)
Thanks for your great input!
th