bashposixcharacter-class

Print POSIX character class


Given a class, such as

[:digit:]

I would like the output to be

0123456789

Note, the method should work for all POSIX character classes. Here is what I have tried

$ printf %s '[:digit:]'
[:digit:]

§ Character classes


Solution

  • $ seq 126 | awk '{printf "%c", $0}' | grep -o '[[:digit:]]'
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9