BASH + Best method of converting fields to variables

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Sat Jul 17 20:55:31 UTC 2004


Am Sa, den 17.07.2004 schrieb Ow Mun Heng um 22:03:

> > How about using the IFS variable for this ?
> > set IFS to ':' and run a for...done loop over each line of the input file.
> 
> I'm not sure how that can be used. 
> 
> One other thing which I found is that by using awk, I'm actually
> processing the file all at once. (as the awk code above shows). I'm not
> sure how I can get BASH to actually process it line-per-line like tcsh's
> foreach.
> 
> Maybe I can learn up on using awk's $NR variable, to get it to
> auto-increment so that I read it line-by-line and process it that way.
> 
> Right now, my random password generator function is making the _same_
> default password for _all_ users. That's Not too great.

cat /etc/passwd | while read line; do
      whatever ...
done

Sorry, I don't really understand what you want to do with the content of
the password file. Maybe you can explain your target a bit more.

Alexander


-- 
Alexander Dalloz | Enger, Germany | GPG key 1024D/ED695653 1999-07-13
Fedora GNU/Linux Core 2 (Tettnang) Athlon CPU kernel 2.6.6-1.435.2.3.uml
Serendipity 22:50:43 up 4 days, 20:33, load average: 0.20, 0.37, 0.37 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20040717/a9107f40/attachment-0001.sig>


More information about the fedora-list mailing list