LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-17-2012, 02:00 AM   #1
erudite
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Rep: Reputation: Disabled
shell script to print the groups of the users.


xxx

Last edited by erudite; 04-17-2012 at 05:22 AM.
 
Old 04-17-2012, 02:45 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

This looks like homework, which we will not do for you. We are willing to help though.

What have you tried and what did or did not work?

Hints: Use a loop to read the user names and have a look at the id command.

Hope this helps.
 
Old 04-17-2012, 02:47 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
It's your job, intended to train you (not us), so what have you tried so far?
 
Old 04-17-2012, 03:09 AM   #4
erudite
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
nope..it isnt a homework..i was just trying different possible stuff i can do since i just satrted learning bash shell..What i thought of is having a loop..but how to proceed i dont know..

So plz plz give the algorithm for this..
 
Old 04-17-2012, 03:16 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Have a look at this:
Code:
while read NAME; do echo -n "${NAME} : " ; id -nG ${NAME}; done < infile
Or as full script:
Code:
#!/bin/bash

while read NAME
do
  echo -n "${NAME} : "
  id -nG ${NAME}
done < infile
I leave it up to you to figure out how this works, that way you'll actually learn something.

Hope this helps.
 
Old 04-17-2012, 03:38 AM   #6
erudite
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
xxx

Last edited by erudite; 04-17-2012 at 05:22 AM.
 
Old 04-17-2012, 03:54 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

If you use a while loop (see post #5) you don't need the export user=`cat groups.sh.....` part.

Hope this helps.
 
  


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
Menu bashed shell script for users shell 0.o Linux - Server 6 02-14-2013 06:00 AM
print 1 to 100 in a shell script sleeper0110 Programming 5 11-02-2008 04:55 AM
shell script to print ldap users cmontr Programming 3 08-19-2008 01:43 PM
How to print my process id using shell script ik_nitk Programming 4 06-07-2007 12:23 AM


All times are GMT -5. The time now is 08:16 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration