- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- grep -A option - Illegal option issue
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
04-08-2006 07:14 PM
04-08-2006 07:14 PM
I'm attempting to use the grep -A option i.e. to print the number of lines of trailing context after the matching lines.
I'm wanting to extract the values between the tags in a XML file. I've attempted the method below:
prod-cingtuna\ :/mkl/users/lows >grep -A1 -E '(>URLString<|>title<)' sample.xml
grep: illegal option -- A
Usage: grep [-c|-l|-q] [-bhinsvwx] pattern_list [file ...]
grep [-c|-l|-q] [-bhinsvwx] [-e pattern_list]... [-f pattern_file]... [file...]
grep -E [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
grep -E [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
grep -F [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
grep -F [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
prod-cingtuna\ :/mkl/users/lows >which grep
/usr/xpg4/bin/grep
prod-cingtuna\ :/mkl/users/lows>
/usr/bin/grep -A1 -E '(>URLString<|>title<)' sample.xml
/usr/bin/grep: illegal option -- A
/usr/bin/grep: illegal option -- 1
/usr/bin/grep: illegal option -- E
Usage: grep -hblcnsviw pattern file . . .
However, as shown above, the grep utility didn't seem to recognize the -A option. I've used grep utilities from /usr/bin/grep and /usr/xpg4/bin/grep.
I've checked the URL http://unixhelp.ed.ac.uk/CGI/man-cgi?grep
for the grep options and -A is a valid option.
Attached is the XML file which I'm attempting to "grep" values between the specific tag.
May I know which grep version or location of grep would have the -A option?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2006 07:37 PM
04-08-2006 07:37 PM
Re: grep -A option - Illegal option issue
the URL and -A option is for gnu grep, which you have to download and install first. You can probably find a suitable version of that at Merijn's site:
http://www.hpux.ws/merijn/
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2006 07:38 PM
04-08-2006 07:38 PM
Solution-A is not a valid option for the standard hp-ux grep.
I have checked egrep and it is also not valid.
You may wish to see http://www.gnu.org
They may have a grep that runs on HP-UX that meets your need.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2006 09:15 PM
04-08-2006 09:15 PM
Re: grep -A option - Illegal option issue
I've tested the grep -A option on a Linux machine and it did not produce the error "illegal option".
Thanks very much for the advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2006 09:16 PM
04-08-2006 09:16 PM