The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep command christine33990 UNIX for Dummies Questions & Answers 11 05-06-2008 02:45 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 02:59 AM
grep command help ishmael^soyuz Shell Programming and Scripting 4 07-11-2007 09:01 AM
grep command pmsuper UNIX for Dummies Questions & Answers 6 11-22-2006 07:12 AM
grep command debasis.mishra Shell Programming and Scripting 1 03-28-2006 01:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2002
april04 april04 is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 8
Unhappy grep command ~ Need help

Hello All

I am new to here and shell scripting ... and I need some help please

In /etc/group, how can I just grep the group that I want instead of the whole list? I just want "testabc", what do I have to do to get the "testabc" group information instead of all 4!

Thanks a lot for helping

For example:
In /etc/group
testabc
testabc1
testabc2
testabc3
  #2 (permalink)  
Old 10-23-2002
janr janr is offline
Registered User
  
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
Depend on the version of grep you are using.

Look in the man page

or try this
grep -w testabc /etc/group

Please post your OS-type
  #3 (permalink)  
Old 10-23-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
You can also quote your word with a trailing blank to get a literal query.

grep "testabc " /etc/group


  #4 (permalink)  
Old 10-23-2002
april04 april04 is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 8
Unhappy

Hello again...

I use both Sun & HP OS

Thanks for the reply
I am not sure what I did wrong, but it doesnt work

May be I shouldnt use grep command? Any other suggestion?
What will be the best way to grab the "word (group name)" information alternately on the group in /etc/group?

Thanks again

testabc
testabc1
testabc2
testabc3
  #5 (permalink)  
Old 10-23-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
I would think that the -w trick would work on SunOS. Which version are you using?

But give this a try:
grep "^testabc:" /etc/group
  #6 (permalink)  
Old 10-23-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
I use HPUX as well. This works.

When you are saying it doesn't work, do you mean that you can't get ONLY the first word? but instead get the whole line?

Then use this.

grep "^testabc" /etc/group |awk -F: '{ print $1 }'

This will give you ONLY the word "testabc".
  #7 (permalink)  
Old 10-23-2002
april04 april04 is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 8
Talking

Thank You All for Helping...
I think I Got it


Last edited by april04; 10-23-2002 at 04:03 PM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0