- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- General
- >
- RE match pattern used in grep command
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- Report Inappropriate Content
11-20-2003 12:36 AM
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP