Re: OT: bash script for passwd and shadow manipulation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Nov 27, 2008 at 01:56:11PM -0500, Erick Perez wrote:
> So far, cut returns the name up to the space, so in this case it will
> return Kimaura and not Kimaura Thomas.

No, it doesn't.

> # for linia in `cat /etc/passwd`

This is your mistake.  Think about it
  for linia in `cat /etc/passwd`
  do
    echo Line just read: $linia
  done

That shows what is going wrong; the "in" is splitting at the white space.

What you should be doing
  cat /etc/passwd | while read linia
instead.

Even better would be
  while read linia
  do
   ....
  done < /etc/passwd

Or, to rewrite the whole program in a one line awk script:

awk -F: '{printf("zmprov ma %s@'$domain' displayName %s\n",$1,$5)}' /etc/passwd > $file

-- 

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux