Reputation: 23
Why does this command work
echo -ne "\x74\x79\xf4"|grep -aPo "\x74\x79"
and this doesn't?
echo -ne "\x74\x79\xf4"|grep -aPo "\x74\x79\xf4"
Upvotes: 2
Views: 170
Reputation: 626758
The following will work:
echo -ne "\x74\x79\xC3\xB4" | grep -aPo "\x74\x79\xf4"
# ^^^^^^^
echo -ne "\x74\x79\u00F4" | grep -aPo "\x74\x79\xf4"
# ^^^^^^
The \xF4
is not a single byte, it consists of two bytes, C3
and B4
. Thus, to encode it properly in the echo
command, you need to use \xC3\xB4
sequence.
With \u00F4
, you specify the code unit.
Upvotes: 2