Sample Header Ad - 728x90

grep a range of characters (decimal encoding)

4 votes
1 answer
810 views
I have a list of accepted characters: !"#$%&'()*+,-./0123456789:;?@ABCDEFGHI These characters can be translated in the ASCII decimal range 33-73 The implementation I'd like would parse the lines of an input file, detecting any character out of this range, and returning the corresponding line. grep -E '[^33-73]{1,}' where -E is for regex interpretation, ^ is for matching any characters NOT in the list, {1,}is for matching one or more occurrences... and [33-73] is a way to symbolize the wanted range of characters in decimal format, I don't know how to express this in a way it's interpretable by grep. (I could define the list of characters in the regex itself, but escaping of reserved grep -E characters makes the expression hard to read.) Is there a way to implement this in grep? (FYI trying to make it work on (BSD grep) 2.5.1-FreeBSD) Example input:
$ cat f1.txt
(ABC123abc_
ABC!123)-
Expected output: (ABC123abc_
Asked by aechchiki (243 rep)
Oct 13, 2021, 10:01 AM
Last activity: Oct 13, 2021, 11:53 AM