- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- RE match pattern used in grep command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 09:52 PM
тАО11-19-2003 09:52 PM
A script provided by my HP Account engineer requested me the system handle of my box. But the following error messages was repoted:
Unprintable character in 'MYSYSTEM-9000'.
I debbuged that script and found the lines that check my input:
if [ "`echo $user_info | grep '^[ !-~]*$'`" = "" ]
then
echo ""
echo "Unprintable character in '$user_info'."
continue
fi
The problem was the grep command. The following command line prints nothing:
echo hello | grep '^[ !-~]*$'
but the following alternate command line works fine:
echo hello | LANG= grep '^[ !-~]*$'
hello
I notice that grep command runs fine or not according to NLS environment (my usual LANG value is es_ES.iso88591) but what is NLS-dependant on that match pattern [ !-~] ?
According to ASCII table [ !-~] should be equivalent to [ -~] because "space" char and "!" are consecutive. This range includes all printable 7-bit ASCII characters. Therefore no problems related to NLS should be appear, shouldn't it ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 10:01 PM
тАО11-19-2003 10:01 PM
Re: RE match pattern used in grep command
Just try different patterns for your grep RE to see if it is indeed the ' !' that is causing the problem or the '~' character...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 11:09 PM
тАО11-19-2003 11:09 PM
Re: RE match pattern used in grep command
Not clear understand what are you trying to do. The first of your command (echo hello | grep '^[ !-~]*$') output nothing because where are no any of ^[ !-~]*$ characters in the world "hello". So no matches. The second command you printed assigns string value
# echo hello | LANG=grep'^[ !-~]*$'
output nothing
# echo $LANG
grep^[ !-~]*$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 11:17 PM
тАО11-19-2003 11:17 PM
Re: RE match pattern used in grep command
if grep does not find any of the strange characters it looks for, the if sentence will be true:
if [ "" = "" ]
under which circumstances it says that there is an unprintable character.
Is there not the slightest possibility that a not operator is missing, e.g.:
if [ "`echo $user_info | grep '^[ !-~]*$'`" != "" ]
Just wondering...
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 11:47 PM
тАО11-19-2003 11:47 PM
Re: RE match pattern used in grep command
1) the match pattern [ !-~ ] means to match any character that is:
a space (ASCII code 32)
or
any char between ! (ASCII code 31) and ~ (ASCII code 126)... this means any ASCII char.
2) There is a space char between the sign = and 'grep' word, then I'm assigning nothing to LANG variable.
I checked LC_COLLATE section in file /usr/lib/nls/loc/src/es_ES.iso885915.src
and found a strange order. Meanwhile order found in C.src is identical to ASCII char, order set in es_ES.iso88591.src doesn't look to be right (perhaps).
I tried another tests:
$ echo hello | LANG= grep '^["-z]*$'
hello
$ echo hello | LANG=es_ES.iso88591 grep '^["-z]*$'
grep: Rango no v├Г┬бlido en expresi├Г┬│n [].
The error messages appears in Spanish.
The translation is:
grep: Invalid range within [] expression.
The same behaviour is found when other values (as it_IT.roman8) for LANG are us
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 12:36 AM