- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: strange behavior?
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-23-2003 08:15 PM
07-23-2003 08:15 PM
strange behavior?
as yourself and in your homedir,
export T=9 # the T is arbitrary
echo $T # should return 9
echo $T | grep [0-9] # should still return 9
cd /
echo $T | grep [0-9] # returns nothing and echo $? is 1
echo $T | grep [1-9] # returns nothing as well
echo $T | grep [2-9] # returns a 9
Root is the only place I have seen the grep fail. Why? Put quotes around the brackets and your fine. This doesn't sound normal....
This is an HP 11.0 system. The shell is KSH (altho I have seen this with CSH)
On this system, the version of ksh is 82.10.1.61 (PHCO_27418)
I have not seen this problem on systems without this version of ksh. But I have one system with this version of ksh which works 'as expected'.
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2003 08:27 PM
07-23-2003 08:27 PM
Re: strange behavior?
# echo $SHELL
# which sh
# which ksh
# /usr/bin/sh <script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2003 08:29 PM
07-23-2003 08:29 PM
Re: strange behavior?
Well I have seen differing results between 2 similar servers
1st result was vice versa to yours but ok in my ~dir and / apart from
echo $T | grep [1-9]
Didn;t return enything
PHCO_22712 1.0 ksh(1) cumulative patch
On March QP machine different again
OK in ~dir and in / but also get return from all perms of grep
QPK1100 B.11.00.60.4 Quality Pack for HP-UX 11.00, March 2003
Hmmm
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 01:22 PM
07-30-2003 01:22 PM
Re: strange behavior?
which sh results in /usr/bin/sh
which ksh results in /usr/bin/ksh
I beleive the user has tried his script using sh, but will ask.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 04:49 PM
07-30-2003 04:49 PM
Re: strange behavior?
Remember the shell will first attempt filename expansion when dealing with []. It will pass '[0-9]' to grep only if it doesn't find any files named 0 thru 9; Otherwise, it will pass a list of matching files (eg grep 3 5 7) to mess things up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 04:51 PM
07-30-2003 04:51 PM
Re: strange behavior?
Oh yeah, may I suggest using grep -E '^[0-9]$' ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 05:18 PM
07-30-2003 05:18 PM
Re: strange behavior?
I agree with Jordan. If you have any files called 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 it will fail.
Check in / and I bet you find a file called 1 (and possibly 0).
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 07:43 PM
07-30-2003 07:43 PM
Re: strange behavior?
the reason the this test failed - was because there was a file named 1 in the root directory ofthe first box I tested. This test will fail for any directory which happens to have a numbered file in it.
thanks all for you help!