HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- use grep command
Operating System - HP-UX
1833457
Members
2760
Online
110052
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-18-2002 04:39 AM
09-18-2002 04:39 AM
Hi,
how would I do the following commands?
Here is the file.
1. need to print where the persons first name starts with S.
2. Print lines where birthdays are in December.
3. print phone number in the 293 area code.
4. Last name begins with K or k
5. print lines preceded by a line where the salary is a six-figure digit.
Ephram Hardy:293-259-5395:235 CarltonLane, Joliet, IL 73858:8/12/20:56700
James Ikeda:834-938-8376:23445 Aster Ave., Allentown, NJ 83745:12/1/38:45000
Barbara Kertz:385-573-8326:832 Ponce Drive, Gary, IN 83756:12/1/46:268500
Lesley Kirstin:408-456-1234:4 Harvard Square, Boston, MA 02133:4/22/62:52600
William Kopf:846-836-2837:6937 Ware Road, Milton, PA 93756:9/21/46:43500
Sir Lancelot:837-835-8257:474 Camelot Boulevard, Bath, WY 28356:5/13/69:24500
Your time and help is greatly appreciated.
how would I do the following commands?
Here is the file.
1. need to print where the persons first name starts with S.
2. Print lines where birthdays are in December.
3. print phone number in the 293 area code.
4. Last name begins with K or k
5. print lines preceded by a line where the salary is a six-figure digit.
Ephram Hardy:293-259-5395:235 CarltonLane, Joliet, IL 73858:8/12/20:56700
James Ikeda:834-938-8376:23445 Aster Ave., Allentown, NJ 83745:12/1/38:45000
Barbara Kertz:385-573-8326:832 Ponce Drive, Gary, IN 83756:12/1/46:268500
Lesley Kirstin:408-456-1234:4 Harvard Square, Boston, MA 02133:4/22/62:52600
William Kopf:846-836-2837:6937 Ware Road, Milton, PA 93756:9/21/46:43500
Sir Lancelot:837-835-8257:474 Camelot Boulevard, Bath, WY 28356:5/13/69:24500
Your time and help is greatly appreciated.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 04:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 06:08 AM
09-18-2002 06:08 AM
Re: use grep command
If you wanted to avoid grep altogether, here's the answer for question 1.
awk '$1~/^S/{print $0}' file
Robin did a great job on the rest of them.
Now, for grins, let's combine questions 1-4 into a one line command (using awk, what else?)
awk '$1~/^S/ && $2~/^[Kk]/{print $0}' |
awk -F: '$2~/^293/ && $4~/^12/{print $0}'
Robin uses "print" while I use "print $0" (either I am too frequent of a user of shift, or I am just too "old school" with awk.)
awk '$1~/^S/{print $0}' file
Robin did a great job on the rest of them.
Now, for grins, let's combine questions 1-4 into a one line command (using awk, what else?)
awk '$1~/^S/ && $2~/^[Kk]/{print $0}' |
awk -F: '$2~/^293/ && $4~/^12/{print $0}'
Robin uses "print" while I use "print $0" (either I am too frequent of a user of shift, or I am just too "old school" with awk.)
"Any sufficiently advanced technology can be indistinguishable from magic" Arthur C. Clarke. My corollary - "Any advanced technology can be crushed with a sufficently large enough rock."
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP