I don't know about awk and sed, but have you considered using "join"?
If you make your list of usernames of a format something like:
jones:Michael Jones
smith:Paul Smith
then you should be able to join the two files specifying field 1 as
the join field.
Now, assuming file1 is your password file, and file2 is your username
file, use something like the following to write your file to standard
output:
join -a1 -o 1.1 1.2 1.3 1.4 2.2 1.6 1.7 -t ":" file1 file2
-a1 use all lines in file1 to form output file
-o m.n output field n from file m
-t specifies field separator
I haven't tried it, but something very close should work.
Mike Jenkins
Perth, Western Australia
Ph 08 9323 5544, Mob 0409 085 802
----- Original Message -----
From: Hugo Bouckaert <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday 23 September 1999 11:19
Subject: another sed & awk problem
Thanks to everyone who helped me out with my previous problem
regarding
making links using sed. It worked!
I hope I am not too repetitive if I ask another question regarding the
use of sed and awk. Please ignore the problem outlined below if you
find
it annoying.
The second question I have is regarding insertion of a name in the
fifth
field of a password file.
The password file has username, UID, GID already but is missing the
full
name in the fifth field, eg
I have a password file with several entries:
jones::5001:5000::/home/bilby/forensic/jones:/bin/zsh
smith::5002:5000::/home/bilby/forensic/smith:/bin/zsh
In the fifth field I would like to insert names. They are sorted in a
file and match the lines in the password file so that from a file
which
contains:
Michael Jones
Paul Smith
etc
I would like to end up with:
jones::5001:5000:Michael Jones:/home/bilby/forensic/jones:/bin/zsh
smith::5002:5000:Paul Smith:/home/bilby/forensic/smith:/bin/zsh
The problems is that this process requires two input files ie the file
containing the names and the password file. Therefore a loop using
for i in `cat $1`
cannot be used as $1 either refers to the file with names or the
password file and not to both.
Is there any way of doing this, maybe a combination of sed and awk?
I hope I am not exhausting people's patience with these questions.
Thanks in advance
Hugo
--
Dr Hugo Bouckaert - Systems Administrator, Computer Science UWA
Tel: +(61 8) 9380 2878 / Fax: +(61 8) 9380 1089
Email: [EMAIL PROTECTED] / Web: http://www.cs.uwa.edu.au/~hugo
-====---====---====---====---====---====---====---====---====---====--
-====-
to unsubscribe email "unsubscribe linux-admin" to
[EMAIL PROTECTED]
See the linux-admin FAQ: http://www.kalug.lug.net/linux-admin-FAQ/