LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-09-2016, 09:42 PM   #1
shravankumar.ank
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:
sys-admin

Group Connections:
webdeveloper
oracle-dba

Terminal :

linux-host

Mode:

Admin,Auditor
======================================
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, 01:23 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,515

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

Rep: Reputation: 21
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.
 
  


Reply


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 11:58 AM
[SOLVED] SED search and replace fields in a fixed position based on a condition. jfkse7en Programming 7 01-06-2012 06:14 AM
Sed/awk/grep search for number string of variable length in text file Alexr Linux - Newbie 10 01-19-2010 01:34 PM
Sed, Awk, grep,Search,delete joyds219 Linux - Newbie 6 04-03-2008 06:15 AM
search for specific text in fields using awk Helene Programming 2 04-23-2004 12:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:31 AM.

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