- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Scriptng Issue: Different output on HPUX and L...
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
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
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
08-11-2011 10:47 AM
08-11-2011 10:47 AM
Scriptng Issue: Different output on HPUX and Linux
Hi All,
Please help. I have a file called file1:
# more file1
ab12
bc34
xy89
q123
gone
1234
When I run this command on HPUX, it gives me the output as below:
[root@HPUX:/var/tmp]
# cat dewa |grep -v -E "^[A-z][A-z][0-9][0-9]|^[A-z][0-9][0-9][0-9]"
gone
1234
However, if I run the same command on Linux, it gives me different output which is not correct.
[root@Linux:/var/tmp]
# cat dewa |grep -v -E "^[A-z][A-z][0-9][0-9]|^[A-z][0-9][0-9][0-9]"
ab12
bc34
xy89
q123
gone
1234
What is the issue? How to make the output on Linux the same as what I get on HPUX?
Thanks for your help.
Regards,
Dewa
- Tags:
- regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2011 12:10 PM
08-11-2011 12:10 PM
Re: Scriptng Issue: Different output on HPUX and Linux
Hi:
First, though I adore cats we don't need to bring them into this.
Now, instead of:
# grep -v -E "^[A-z][A-z][0-9][0-9]|^[A-z][0-9][0-9][0-9]" file
Use:
grep -v -E "^[A-Za-z][A-Za-z][0-9][0-9]|^[A-Za-z][0-9][0-9][0-9]" file
...that is well defined ranges. I would also re-write the last to this:
# grep -v -E "^([A-Za-z][A-Za-z][0-9][0-9]|[A-Za-z][0-9][0-9][0-9])" file
Regards!
...JRF...
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2011 12:45 PM
08-11-2011 12:45 PM
Re: Scriptng Issue: Different output on HPUX and Linux
Hi (again):
Interestingly using a Centos 5.6 distribution I also find that this will give you the result you want:
# grep -v -E "^([a-Z][a-Z][0-9][0-9]|^[a-Z][0-9][0-9][0-9])" file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 03:03 AM
08-12-2011 03:03 AM
Re: Scriptng Issue: Different output on HPUX and Linux
The default grep on HP-UX is not the GNU version:
$ /usr/bin/grep --version /usr/bin/grep: illegal option -- - usage: grep [-E|-F] [-c|-l|-q] [-bhinsvwx] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-bhinsvwx] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-bhinsvwx] pattern [file...]
If you would install the GNU version (somewhere)
$ /pro/local/bin/grep --version grep (GNU grep) 2.5.1 Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Their regular expression engines do not match (at all). To add to this confusion, one can select different matching engines in GNU grep is so configured
Regexp selection and interpretation: -E, --extended-regexp PATTERN is an extended regular expression -F, --fixed-strings PATTERN is a set of newline-separated strings -G, --basic-regexp PATTERN is a basic regular expression -P, --perl-regexp PATTERN is a Perl regular expression
Being a perl freak, you'll understand that I use -P quite often: I know that syntax, and it is portable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 05:13 AM
08-12-2011 05:13 AM
Re: Scriptng Issue: Different output on HPUX and Linux
Hey;
>>First, though I adore cats we don't need to bring them into this.
Nicest presentation of the "Useless use of cat award" that iI've seen in ages!
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Tags:
- evil cat