- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Newbie question - Grep
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
05-08-2001 09:05 AM
05-08-2001 09:05 AM
I want to get out all the usernames with 6 characters in them.
Can some one please help me out with the syntax.
So far i have tried -
cat file|grep ??????
also tried enclosing the ?'s in quotes, but that didn't work.
I have looked at the man for grep but i cannot see anything that might work ....
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2001 09:16 AM
05-08-2001 09:16 AM
SolutionYou might have a problem just generically searching for any 6 char items in the list. You might be able to use "grep '......' filename", which will look for any entries with any characters (the . is any one character), but this will probably grab every line in filename, since spaces might be included. You can use special characters to search the beginning of the line or to limit by looking at letters only, caps, numbers, etc. Can you be more specific about the file? Grep is really powerful, but getting the regular expressions down can be a pain.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2001 09:23 AM
05-08-2001 09:23 AM
Re: Newbie question - Grep
Since the file i'm using is a straight list of usernames, each one on a seperate line there are no worries about spaces ...
So if i use -
cat file|grep '......'|grep -v '.......'
That gives me what i want :O)
Once again thanks :O)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2001 09:50 AM
05-08-2001 09:50 AM
Re: Newbie question - Grep
I think I have found an expression that will work, assuming that the user names in the file are all the first items on the lines and have info after them. Try
grep '^[A-Za-z]\{6\}[ ]' filename
This should look at the beginning of each line (^) for any line with 6 lower or upper case alpha characters ([A-Za-z]\{6\}) followed by a space ([ ]). Hope this helps.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2001 01:02 PM
05-08-2001 01:02 PM
Re: Newbie question - Grep
awk 'length($0)==6{print $0}' filename
perl -ne 'print if length == 7' filename
sed -ne '/^......$/p' filename