Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-09-2016, 10:42 PM   #1
LQ Newbie
Registered: Mar 2016
Posts: 1

Rep: Reputation: Disabled
Need help in search particular fields using grep/awk/sed

Hello All,

I work for a company, who uses a third party tool to manage Unix accounts. I have been recently given a task to get a secondary groups for each user from bunch of servers. The tool offers various commands to query user information but it does not have a proper command to query secondary groups. So only option left for me is to capture the secondary groups from an output of command using grep/awk/sed statements . Here's how the output looks like :
Date for user "xyzuser":
Primary Group:

Group Connections:

Terminal :



This is a Linux Server and I want to be able to just capture only "webdeveloper" and "oracle-dba" files in proper way and output to a text file. I have tried lot of awk/sed commands ( not a expert ) but I had no luck.

I appreciate if anyone help me with this task. It will be huge help .
Old 03-10-2016, 02:23 AM   #2
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,579

Rep: Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914
Please show what you have tried?
Old 03-10-2016, 02:42 AM   #3
Stéphane Ascoët
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 187

Rep: Reputation: 41
I've done something like this a long time ago, with the help of a colleague, in Gawk. The idea was to have a first loop using delimiters to isolate each user(in your case, in mine it wasn't users) and then find groups(in your case) inside this text area. I still have it somewhere, but not here at the moment.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Awk / Grep / sed rahul090590 Programming 17 06-28-2015 12:58 PM
[SOLVED] SED search and replace fields in a fixed position based on a condition. jfkse7en Programming 7 01-06-2012 07:14 AM
Sed/awk/grep search for number string of variable length in text file Alexr Linux - Newbie 10 01-19-2010 02:34 PM
Sed, Awk, grep,Search,delete joyds219 Linux - Newbie 6 04-03-2008 07:15 AM
search for specific text in fields using awk Helene Programming 2 04-23-2004 01:13 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration