|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get list of user into an array..
Hi,
cut -d: -f1,3 /etc/group >rpt.out I have a doubt in above unix commands. right i am getting list of group user id into rpt.out file. instead i need to store it as an array. could you please tell me how can i get list of user into an array.. If u could tell me give me in perl script code in unix thanks in advance. |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
bash Code:
A=( $(cut -d: -f1,3 /etc/group | tr '\n' ' ') )
echo "Number of elements in array: ${#A[@]}"
echo "Elements of array: ${A[@]}" |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
To emulate cut: Code:
open my $group, '<', '/etc/group';
my @groups = map { my @a = split /:/; $a[0] . ':' . $a[2] } <$group>;
close $group;To create a hash mapped on the group name: Code:
open my $group, '<', '/etc/group';
my %groups = map { my @a = split /:/; $a[0], $a[2] } <$group>;
close $group; |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple list file ls to an array | cyberfrog | Shell Programming and Scripting | 6 | 07-13-2010 01:50 PM |
| How to process list of files as array in the script | IND123 | Shell Programming and Scripting | 1 | 06-07-2010 06:37 AM |
| storing values in a list or array | KiranKumarKarre | Shell Programming and Scripting | 1 | 05-08-2009 12:50 AM |
| Searching for array in large list of files | Rhije | Shell Programming and Scripting | 2 | 01-21-2009 11:11 PM |
| getting data list into a hash array | topcat8 | Shell Programming and Scripting | 5 | 03-09-2004 11:02 AM |
|
|