hi everyone
suppose we have two scenario
echo ABCD | grep [A-Z]\{4\}
DATE
echo SYSDATE | grep [A-Z]\{4\}
SYSDATE
i want to match the string of four length only please help
hi everyone
suppose we have two scenario
echo ABCD | grep [A-Z]\{4\}
DATE
echo SYSDATE | grep [A-Z]\{4\}
SYSDATE
i want to match the string of four length only please help
Could see that the similiar thread is already asked FYI...
You can use the pattern matching from below..
I have tried it and it works..
perl -lne 'print if(/\b\w\w\w\w\b/)'
$ echo "DATE\nSYSDATE" | /usr/xpg4/bin/egrep -e ^[A-Z]{4}$
DATE
echo ABCD|grep '^[A-Z]\{4\}$'
If the solution you choose uses the [A-Z] range expression to match only upper class letters in the English alphabet, make sure you're using the POSIX locale's collation sequence. Otherwise, the range expression is technically undefined (according to the standard) and in practice (e.g. some UTF-8 locales) the collation sequence can interleave lower case letters among the uppercase (aAbBcCdD...).
Alternatively, you can use the [:upper:] character class if you'd like portability across locales (which means that what consitutes an upper case letter can change when the environment changes). Personally, that fluidity makes me uneasy.
In summary, not ensuring that the posix collation sequence is used plus variation in locale collation sequences plus undefined range expressions plus an `rm [A-Z]*` can result in unplanned rage: What ... the ... #$%@#$@!!! Where did all my lowercase files go?
Regards,
Alister