5 replies
by pingendorf
Here is something that might be able to help you a small shell script that can read a properly formated /etc/passwd file and parse out the name combo you are looking for. run it with the begining uid of the users you want to process and it will runfrom there out. The file is commented so making it run whatever apps you would like from within it useing the parameters of the username the uid the full name or the converted firstname.lastname should be trivial. Hope it helps ps if the formatingdoesn't take you might want to format is before reading it. It will make things much easier.
---CUT HERE---
#!/bin/sh
for passline in `cat /etc/passwd | sed -e 's/ /|/g'`
do
if test -z $1
then
inputid=0
else
inputid=$1
fi
# just grab the userid from the passworf file to compair.
luid=`echo $passline | sed -e 's/ /|/g' | sed -e 's/:/ /g' | awk {print'$3'}`
if test $luid -ge $inputid then
# get the name from the password file of the user
# first we replace spaces with pipes so we can make sure we are spliting on :
# and awking out only theslot for the users name the replacing the pipe
# with a space
name=`echo $passline | sed -e 's/ /|/g' | sed -e 's/:/ /g' | awk {print'$5'} | sed -e 's/\/.*//g' | sed -e 's/|/ /g'` # getting out the user name is fairly simple as it is the first item in the list.
# just grab the line and whack everything after the first : including the first :
luser=`echo $passline | sed -e 's/:.*//g'`
# just in case there is no name you want the name to be the username.
if test -z name
by susan.degnan
by brianbarber
by susan.degnan
by susan.degnan
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending