- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep command
Operating System - HP-UX
1753500
Members
4647
Online
108794
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
Discussions
Discussions
Forums
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
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
тАО07-18-2001 03:59 AM
тАО07-18-2001 03:59 AM
Re: grep command
The hostnames in my hosts file usually have a tab after the name. The following works for me:
grep "hp1[ ]" hosts
The first character in the brackets is a space, the second character is where I pressed the tab key (on my system it actually show many more spaces) That way it will get those that end in spaces or those that end in a tab character.
grep "hp1[ ]" hosts
The first character in the brackets is a space, the second character is where I pressed the tab key (on my system it actually show many more spaces) That way it will get those that end in spaces or those that end in a tab character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 04:31 AM
тАО07-18-2001 04:31 AM
Re: grep command
How about rewriting the whole script ?
Here's what you could du using awk :
awk '
BEGIN {
while (getline <"/etc/hosts") {
for (i=1;i<=NF;i++) {
host[$i]=$0
}
}
while (getline <"/tmp/hplist") {
printf("%s\n",host[$0])
}
}' >/tmp/list
Here's what you could du using awk :
awk '
BEGIN {
while (getline <"/etc/hosts") {
for (i=1;i<=NF;i++) {
host[$i]=$0
}
}
while (getline <"/tmp/hplist") {
printf("%s\n",host[$0])
}
}' >/tmp/list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 04:55 AM
тАО07-18-2001 04:55 AM
Re: grep command
That's it Robin!!! The second code was the right one.
I tried also yours Laurent, it works, but there are some entries that aren't found.
However i'd like to learn something about using awk, it seems very powerful, is there some tutorial on the net?
Thanks both, and of course thanks to all for your kindly help.
Regards
Tarek
I tried also yours Laurent, it works, but there are some entries that aren't found.
However i'd like to learn something about using awk, it seems very powerful, is there some tutorial on the net?
Thanks both, and of course thanks to all for your kindly help.
Regards
Tarek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 05:26 AM
- « Previous
-
- 1
- 2
- Next »
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP