[CentOS] OT: bash script for passwd and shadow manipulation

Erick Perez eaperezh at gmail.com
Thu Nov 27 20:35:25 UTC 2008


>>
>
> You should be able to do this easily with awk.  Look at the -F option for
> defining fields.  The follow command line will pluck field 1 and field 5
> from your example.
> $ echo "k.thomas:x:1918:100:Kimaura Thomas:/home/users/k.thomas:/bin/usersh"
> | awk -F : '{ print $1", "$5 }'
> Or, in your script
> .
> .
> .
> user=echo $linea | awk -F :  '{ print $1 }'
> nombre=echo $linea | awk -F :  '{ print $5 }'
> .
> .
> .
> That's about as inelegant as it comes but it should be easy to understand.
>  There is a fantastic (g)awk manual at
> http://www.gnu.org/software/gawk/manual/ presented in a number of formats.
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>

thanks Robert,

If i do what you said
for linia in `cat /etc/passwd`
do
    user=echo $linea | awk -F :  '{ print $1 }'
    nombre=echo $linea | awk -F :  '{ print $5 }'
    echo "the name is $nombre"
    echo "zmprov ma $user@$domain displayName $nombre">>$file

    x=$[x+1]
done

then I have:
the name is echo

So it seems i have problems with quotes...
either " or ` goes somewhere....
now..on my way to reaad about escape sequences in echo.

-- 
------------------------------------------------------------
Erick Perez


More information about the CentOS mailing list