Sorting group information for accounts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting group information for accounts
# 8  
Old 08-03-2012
Sounds like a user management nightmare. Maybe they should use some sort of central authentication server.

The modification you described for changing 4 to 11, and getent to cat group are both correct. But in the case of cat group, you could just use while ((getline < "group_file") > 0)

the "it doesn't exist error" is because a user had a GID that the group_file doesn't... the ones it has will still be correct.
# 9  
Old 08-04-2012
Just a quick note - it is a central management system called KeON but it's split into security domains: development, testing, production, and I dunno how to describe the fourth one. All the development servers communicate within the development domain and so on. Within each domain they have their own ldap implementations, but it took us a while to develop a central GID reservation database. Until that happened some groups were implemented with different GID's then the same group in a different domain. It's a nightmare fo sho Smilie

Btw I've been googling this "getline" business. I don't understand why it's any different than redirection? I found this little sample kludge for an exercise on a tutorial site I found:
Code:
#!/usr/bin/awk -f

BEGIN {FS="[ :\t]"; "date" | getline d; print "The Current Date is: "d;
print "#################################################"}

How is it different than this:
Code:
#!/bin/bash

d=`date`
echo "The Current Date is: "$d
echo "#################################################"

I realise you can accomplish things in several different ways and methods but what is the use of getline when all you need to is direct standard output?

Last edited by MaindotC; 08-04-2012 at 12:44 AM..
# 10  
Old 08-04-2012
Quote:
Originally Posted by MaindotC
... ... ...

Code:
#!/usr/bin/awk -f

BEGIN {FS="[ :\t]"; "date" | getline d; print "The Current Date is: "d;
print "#################################################"}

How is it different than this:
Code:
#!/bin/bash

d=`date`
echo "The Current Date is: "$d
echo "#################################################"

I realise you can accomplish things in several different ways and methods but what is the use of getline when all you need to is direct standard output?
In this specific case, the difference is that for the first nine days of each month, the awk form preserves the two spaces between <abbreviated month name> and <day of month>. That difference would be removed if you replace:
Code:
echo "The Current Date is: "$d

with:
Code:
echo "The Current Date is: $d"

But, presumably, you're writing an awk script to do a lot more than just print these two header lines. Why do you want to go through the overhead of starting up a shell to print the header lines with bash and do the rest of your processing with awk when awk can do it just as easily?
# 11  
Old 08-04-2012
Well, I just wasn't sure what the purpose of the "getline" function was compared to the use of redirection. I'm still googling and re-reading the man page at the moment.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

HELP on 'sectional' or 'group' sorting

Hi, I need to do some section/group sorting. At the moment, I get around it by grep group by group and then re-directing to the same 'final' output file. Below is what's been sorted so far based on the second field $ awk -F"," '{ { print $5 " == " $6 } }' /tmp/x.csv | grep -v "^env" | grep... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Sorting group of records and loading last record

Hi Everyone, I have below record set. File is fixed widht file 101newjersyus 20150110 101nboston us 20150103 102boston us 20140106 102boston us 20140103 I need to group record based on first 3 letters in our case(101 and 102) and sort last 8 digit in ascending order and print only... (4 Replies)
Discussion started by: patricjemmy6
4 Replies

3. Shell Programming and Scripting

New To UNIX - Need Script to create report of user & group accounts

Hi, I'm new to the world of UNIX and have been asked to create a complex script (at least complex to me:confused:) for AIX UNIX to create a report of all the users on the server including server, user, UID, groups, GID, etc. Found a script using lsuser, but the output is still lacking. 2 things I... (2 Replies)
Discussion started by: panthur
2 Replies

4. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies

5. Shell Programming and Scripting

Sorting a list of filenames but keeping the path information.

Hi All I've googled around for this and can't see a way of doing it. I have a file that contains a number of records that are layed out something like the following. /path/to/directory/that/contains/a/file/I/need/filename.pdf The path itself can vary both in terms of the names and the... (7 Replies)
Discussion started by: Bashingaway
7 Replies

6. Shell Programming and Scripting

Group on the basis of common text in the square bracket and sorting

File A 99 >ac >ss >juk 70 >acb >defa 90 >ca 100 >aa >abc >bca 85 >cde 81 >ghi >ghij 87 >def >fgh <ijk 89 >fck >ghij >kill >aa The given output shud be 100 >aa >abc >bca 87 >def >fgh <ijk 89 >fck >ghij >kill >aa (2 Replies)
Discussion started by: cdfd123
2 Replies

7. UNIX for Dummies Questions & Answers

Getting information from /etc/group

How can I retrieve the group id of an entry in the /etc/group file given the group name? I tried using cut and grep but cant get around the problem.. I think this problem can be solved using these commands but I dont know how (I am a newbie at this) (11 Replies)
Discussion started by: sleepster
11 Replies
Login or Register to Ask a Question