migrating system files (info)
Brad De Vries
devriesbj
Mon May 17 11:54:17 PDT 2004
Thanks for going Off Topic on this, my head was
starting to hurt from reading the other posts. I
think it might have been withdrawl symptoms.
Anyway, to pass assignmment values into an awk script,
use the -v option:
for i in `awk -F: ' ($3 > 99) && ($3 < 65530) { print
$1}' /etc/passwd`;
do
awk -F: -v name=$i '$1 == name {print $0}'
/etc/gshadow >> /tmp/gshadow
awk -F: -v name=$i '$1 == name {print $0}'
/etc/group >> /tmp/group
awk -F: -v name=$i '$1 == name {print $0}'
/etc/shadow >> /tmp/shadow
done
HTH,
Brad.
--- Keith Morse <kgmorse at mpcu.com> wrote:
>
> Admittedly, this message isn't about self
> gratification, mental or
> physical. Nor does it deride SCO, Microsoft, or any
> other targets we like
> to detest. Hence it may be considered Off Topic.
> But what the hell, I'll
> test the waters.
>
>
> Thiw is somewhat a followup to Michael Hipp's
> question about password
> issues when migrating to a new server. To support
> this effort, I spent
> that last few hours beating my head against the wall
> trying to figure out
> how to pass command line variables to awk and then
> use it to pattern
> match.
>
>
> awk -F: ' ($3 > 99) && ($3 < 65530) { print $1}'
> /etc/passwd > passwd
>
> for i in `awk -F: ' ($3 > 99) && ($3 < 65530) {
> print $1}' /etc/passwd`;
> do
> awk -F: '$1 == name {print $0 }' name=$i
> /etc/gshadow
> done >> gshadow
>
>
> for i in `awk -F: ' ($3 > 99) && ($3 < 65530) {
> print $1}' /etc/passwd`;
> do
> awk -F: '$1 == name {print $0 }' name=$i
> /etc/group
> done >> group
>
>
> for i in `awk -F: ' ($3 > 99) && ($3 < 65530) {
> print $1}' /etc/passwd`;
> do
> awk -F: '$1 == name {print $0 }' name=$i
> /etc/shadow
> done >> shadow
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
More information about the Linux-users
mailing list