- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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
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
тАО07-18-2001 12:54 AM
тАО07-18-2001 12:54 AM
For example if i make grep hp1 /etc/hosts i will see all ws that begins with hp1 so also hp12, hp110, hp19 and so on..
I want to find only hp1. I know that with sun the command is grep -w, but this doesn't exist on hp, what is it's correspondance? I looked in the grep's man, but i didn't find it. (maybe i didn't look well!!)
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:18 AM
тАО07-18-2001 01:18 AM
Re: grep command
Try this :
grep 'hp1 ' /etc/hosts
Rgds
Alexander M. Ermes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:27 AM
тАО07-18-2001 01:27 AM
Re: grep command
#!/sbin/sh
echo > /tmp/list
for i in 'cat /tmp/hplist'
do
grep $i /etc/hosts >> /tmp/list
done
I saw that if i put $i between '$i ', the output is wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:34 AM
тАО07-18-2001 01:34 AM
Re: grep command
grep hp1$ /etc/hosts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:45 AM
тАО07-18-2001 01:45 AM
Re: grep command
echo > /tmp/list
for i in 'cat /tmp/hplist'
do
grep $i$ /etc/hosts >> /tmp/list
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:50 AM
тАО07-18-2001 01:50 AM
Re: grep command
grep "$i " ...
instead of
grep '$i ' ...
With single quotes your variable will not be translated, and grep will search for $i (dollar-i) in your file.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 02:44 AM
тАО07-18-2001 02:44 AM
Re: grep command
So the script isn't helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 03:11 AM
тАО07-18-2001 03:11 AM
Re: grep command
where you type space followed by tab in the square brackets.
If this doesn't work, what type of expression is not being captured?
Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 03:19 AM
тАО07-18-2001 03:19 AM
Re: grep command
grep -E "$i( | |$)" /etc/hosts
again, it's space,pipe,tab,pipe,dollar in the brackets.
Robin.