Sponsored Content
Top Forums Shell Programming and Scripting need a one liner to grep a group info from /etc/group and use that result to search passwd file Post 302596635 by balajesuri on Wednesday 8th of February 2012 01:01:00 AM
Old 02-08-2012
There could be more efficient ways. But I'm just extending your attempt to a working solution:
Code:
grep `grep 'tiadm' /etc/group  | awk -F: '{print $4}' | awk -F, '{print $1}'` /etc/passwd

Here's another:
Code:
grep `grep 'tiadm' /etc/group  | sed 's/.*:\([^,]*\),.*/\1/'` /etc/passwd


Last edited by balajesuri; 02-08-2012 at 02:09 AM..
This User Gave Thanks to balajesuri For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep group and passwd file

How can I find find all members in the /etc/password file that belong to the dba group in the /etc/group file? (4 Replies)
Discussion started by: mozartny
4 Replies

2. UNIX for Dummies Questions & Answers

is it really not possible for me to edit the etc/group & the etc/passwd files?

From what I have read it possible to create a new group by editing the etc/group and etc/passwd in UNIX two files but a non-experienced user may face many problems such as destroying the file by mistake ot that his changes to these file does not make any difference. However, there is this... (2 Replies)
Discussion started by: whatev3r
2 Replies

3. Solaris

Secondary group info source

Experts, I know when I use id it shows only the primary group information for the given user, and that info comes from passwd file. When I use groups it shows all groups user are member of, however from where come information given by groups command? grep fmtt3990 /etc/passwd... (6 Replies)
Discussion started by: fmattos
6 Replies

4. Shell Programming and Scripting

Help on capturing /etc/group info.....!!

Gurus I am trying to capture all the data in /etc/group file in a CSV ,thru a fingerprinting engine. For hosts having ,unique group names and Ids ,following code works fine. Trouble starts when on a host,there are multiple groups defined with same name and id. e.g One of my hosts has 8... (10 Replies)
Discussion started by: ak835
10 Replies

5. Shell Programming and Scripting

Sort the file contents in each group....print the group title as well

I've this file and need to sort the data in each group File would look like this ... cat file1.txt Reason : ABC 12345-0023 32123-5400 32442-5333 Reason : DEF 42523-3453 23345-3311 Reason : HIJ 454553-0001 I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Discussion started by: prash184u
11 Replies

6. UNIX for Dummies Questions & Answers

Understanding group and passwd

Hi, I am checking who belong to the dba group , and found that oracle and autosys users are part of this group cat /etc/group | grep dba dba::400:oracle,autosys I thought to found user autosys under group 400 togther with user oracle , but found it in group 1000 as you can see bellow.... (2 Replies)
Discussion started by: yoavbe
2 Replies

7. Shell Programming and Scripting

search file and group values with problematic tab

hi people; the similar topic is being opened in here and here but i have confused with following condition. so i wanted to open a seperate topic. from my file.txt:... ... ... 110105-16:04:04 192.168.1.1 7.1j Port_NODE_MODEL_M_1_8 stopfile=/tmp/10544... (0 Replies)
Discussion started by: gc_sw
0 Replies

8. UNIX for Dummies Questions & Answers

Inconsistency between passwd and group

Hi, I have a passwd file with 3 users belonging to the the root group (gid=0), but the group file does not list these users as members of the root group? Shoud I be worried and apart from manually changing it, how can it be remediated? thx Norgaard (1 Reply)
Discussion started by: Norgaard
1 Replies

9. UNIX for Dummies Questions & Answers

Conflicting GID in group and passwd files.

Hi guys, I have a question. In the passwd file, user johndoe has a GID of 100 which is the group named users in the group file. But if you check the group file, johndoe is not listed under GID 100, but under GID 33, which is the group named videos. Under what group does johndoe really belong,... (1 Reply)
Discussion started by: goldenlight1814
1 Replies

10. UNIX for Beginners Questions & Answers

Printing the user and group info

Hi All, i want to collect all the users info whose id greater than 999 and print the groups information which they belong. example : for user in $(cut -d: -f1,3 /etc/passwd | egrep ':{4}$' | cut -d: -f1); do groups $user; done centos : centos adm wheel systemd-journal balu : balu ... (2 Replies)
Discussion started by: balu1234
2 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 12:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy