Re: Changes in file (huge problem)

terry white <[email protected]>
Newsgroups org.kernel.vger.linux-admin
Message-ID <[email protected]>
... ciao:

: on "12-24-2006" "Mário Gamito" writ:
: Change the second field to the correspondent md5 hash.

    i have no idea how to do that, so it's left to the reader.


=====  start code  =====

#!/bin/sh

#########################################
#	4 fields maximun, 2 mandatory	#
#########################################
#	1	user
#	2	password
#	3	if exist , can be 'name' or 'email'
#	4	if exist is 'email'

#	files:	edit to taste
SRC="source"
DST="destination"

#	let's read it
cat $SRC | \
while read USER PASSWORD REMAINDER ; do

#	process user
echo -n $USER: >> $DST

#	YOUR password md5 hash code goes bere
MD5="*******"
echo -n "$MD5:" >> $DST

#	test for name or email
if [ "$REMAINDER" = "" ]
   then echo "NO_NAME:[email protected]" >> $DST
      continue

#	snag email and/or name
   else NAME=""
        MAIL=""
      for T in `echo "$REMAINDER"`
         do if [ `echo "$T" | fgrep -v "@"` ]
               then NAME="$NAME $T" 		#  <---- adds space
               else MAIL="$T"
            fi
	done

#	finish up
   if [ "$NAME" = "" ]
      then NAME="NO_NAME"
   fi
   NAME=`echo "$NAME" | cut -d " " -f 2-`	#  <---- consumes it
   if [ "$MAIL" != "" ]
      then echo "$NAME:$MAIL" >> $DST
      else echo "$NAME:[email protected]" >> $DST
   fi

fi
done

exit


=====  end code  =====



-- 
... i'm a man, but i can change,
    if i have to , i guess ...

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.