- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Error in user setting making grep behave badly
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
Forums
Discussions
Discussions
Discussions
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
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
07-06-2006 08:28 AM
07-06-2006 08:28 AM
I have an unexpected behaviour for one particular user on my HP-US 11i system
The following command: echo 7 | grep [0-9] is not working properly in a script or on the prompt.
example:
maestro@[dm3czo]echo 7 | grep [0-9]
1: TERM=vt100
1: MAESTROLINES=0
1: PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/maestro:/opt/maestro/bin:.:/opt/syncsort380/lib:/stage/syncsort350/lib ; export PATH
1:SHLIB_PATH=/opt/syncsort/lib:/opt/syncsort380/lib/:/stage/syncsort350/lib; export SHLIB_PATH
1: trap "echo 'logout'" 0
1: umask 007
1:tput sgr0
1:tput sgr0
This is like the content of the .profile is passed to the grep command.
But this command is working just fine for others user:
cfrenett@dm3czo:/home/cfrenett>echo 7 | grep [0-9]
7
I have try to locate the difference in the settings of theses users and I cannot find any major differences.
Do you have an idea where I can look to correct this problem?
Thanks,
Charles.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2006 09:08 AM
07-06-2006 09:08 AM
Re: Error in user setting making grep behave badly
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2006 09:09 AM
07-06-2006 09:09 AM
SolutionThe fix is quite simple
echo 7 | grep '[0-9]'
although a more rigourous test would also anchor the target pattern:
echo "7" | grep -E '^[0-9]$'
This will only match a single digit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2006 09:19 AM
07-06-2006 09:19 AM
Re: Error in user setting making grep behave badly
type grep
type echo
type 7
The type command (actually whence -v) tells you what the string will produce when the shell sees that string. The results should be:
> grep is a tracked alias for /usr/bin/grep
> echo is a shell builtin.
> 7 not found.
then look at the environment by typing the commands:
alias
set
Look for strange character strings in the alias and set commands.
BTW: the PATH statement has several concerns:
/bin hasn't existed for more than a dozen years. The correct path is /usr/bin. /bin is a temporary transition link.
/usr/local/bin should be checked for the correct permissions. The default is 777 which is unacceptable for PATH usage. Make sure /usr/local/bin is 775 or 755.
:.: is in the path. All seasoned admins will agree that having . (the current working directory) is a bad security risk.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2006 11:33 PM
07-06-2006 11:33 PM
Re: Error in user setting making grep behave badly
Clay's response (matching a filename surely put you to the cause of your problem. I want to add:
- your problem is NOT user specific - if you change to the path, where the command was called by that user, every user with read acces to that directory would get that result.
- to get an exact match, you can use
echo 7 | grep -x '[0-9]'
The option '-x' anchors your pattern at the beginning and at the end of a line lile '^[0-9]$' but is valid for the whole match:
egrep -x '[0-9]|aa' matches a line containing exactly one digit or a single 'aa'.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2006 01:12 AM
07-07-2006 01:12 AM
Re: Error in user setting making grep behave badly
The problem was that a file 1 was existing in the home of that user and contains the output of the env commant.
And the correction to the grep resolve my issue.
Thanks again.
Charles.