in reply to Read and parse text file
this is similar to the unix commands:#!perl open (FILEH, "/etc/passwd"); #open the file for read while (<FILEH>) { #while there are still lines in FILEH... chomp; #clear newlines... if ( /root/i ) { # if line contains "root" case insensitive` ($username,$id) = (split /:/)[0,2]; #pull out field one and th +ree print "User: $username, ID: $id\n"; #print junk } }
grep -i root /etc/passwd | awk '{ ... You can figure it out.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Read and parse text file
by RCP (Acolyte) on Feb 24, 2004 at 12:40 UTC | |
|
Re: Re: Read and parse text file
by RCP (Acolyte) on Mar 08, 2004 at 18:23 UTC | |
by Roy Johnson (Monsignor) on Mar 08, 2004 at 18:28 UTC | |
by RCP (Acolyte) on Mar 09, 2004 at 14:36 UTC |