jcdole
December 18, 2015, 11:34am
1
Hello
I would like to make a character range like that :
echo "ABCDEF+1234" | grep -E '[\x26-\x40]'
or
echo "ABCDEF+1234" | grep -E '[\046-\100]'
or
echo "ABCDEF+1234" | grep -E '[&-@]'
Which should works on linux with english language
And works also on linux with french language ( english install and after add french )
On my second laptop ( french ) I got this error :
grep: end of interval invalid
but its works on my server (english)
RudiC
December 18, 2015, 11:49am
2
Would this help?
echo "ABCDEF+1234" | grep -E "[\x26-\x40]"
grep: Invalid range end
echo "ABCDEF+1234" | LC_ALL=C grep -E "[\x26-\x40]"
ABCDEF+1234
---------- Post updated at 17:49 ---------- Previous update was at 17:40 ----------
And this would correctly produce the chars equivalent to the hex codes:
echo "ABCDEF+1234" | LC_ALL=C grep -E "["$'\x26'-$'\x40'"]"
+ grep -E '[&-@]'
ABCDEF+1234
1 Like
jcdole
December 18, 2015, 12:19pm
3
rudic:
Would this help?
echo "ABCDEF+1234" | grep -E "[\x26-\x40]"
grep: Invalid range end
echo "ABCDEF+1234" | LC_ALL=C grep -E "[\x26-\x40]"
ABCDEF+1234
---------- Post updated at 17:49 ---------- Previous update was at 17:40 ----------
And this would correctly produce the chars equivalent to the hex codes:
echo "ABCDEF+1234" | LC_ALL=C grep -E "["$'\x26'-$'\x40'"]"
+ grep -E '[&-@]'
ABCDEF+1234
Is there a way to put some macro LC_ALL=C at the beginning of the script if language is not English and remove it before the grep pipe
jcdole
December 18, 2015, 1:37pm
5
I got it
Put that at the beginning of the script.
export LC_ALL=C
Valid only for the script
Thank you very much for helping