- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using regular expr. in a grep command
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
Discussions
Forums
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
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
тАО09-19-2002 06:13 AM
тАО09-19-2002 06:13 AM
Using regular expr. in a grep command
I want to grep files with a certain prefix and with any combination and digits of numbers.
# grep -L LTA'[0-9]' *
will return only on number. But what if I want to represent any number of numbers? My fantasy dosen't help either.
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2002 06:25 AM
тАО09-19-2002 06:25 AM
Re: Using regular expr. in a grep command
I don't think "L" is a valid grep parm.
And the "l" will only return filenames with that pattern within the file itself. If you want to find filenames then I'd use find & pipe it to grep
find . -name -exec grep 'LTA[0-9]'
for all numbers. And use this format for whatever numbers you wish
find . -name -exec grep 'LTA[24680]'
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2002 06:25 AM
тАО09-19-2002 06:25 AM
Re: Using regular expr. in a grep command
Have you tried a grep/egrep on a grep
ls -l | grep LTA | egrep " [1-9]"
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2002 06:27 AM
тАО09-19-2002 06:27 AM
Re: Using regular expr. in a grep command
A typical regexp for grep would be
grep -L LTA'[0-9][0-9]*' *
This would look for LTA followed by a digit, followed by zero or more additional digits.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2002 06:31 AM
тАО09-19-2002 06:31 AM
Re: Using regular expr. in a grep command
Not sure I understand the question:
grep -lE LTA[0-9]+ *
will list all files containing LTA plus at least one number.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2002 06:45 AM
тАО09-19-2002 06:45 AM
Re: Using regular expr. in a grep command
If you are searching for that pattern within a file you could also use a character class expression:
grep -l LTA"[[:digit:]]" *
This would find the LTA followed by any number of digits.
See man 5 regexp for more on character classes.
Have fun! :-)
Larry