Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
i need help finishing a script that looks through my password directory for two or more users with the same name and print those namesin standard out put this is what i have
myfile- 'etc/passwd';
open$file || or die (Can not open $myfile\n);
while(){
($uname,$password,$uid,$gid,$username,$home,$shell);
printf
}
 
The following should work:

$myfile = '/etc/passwd';
open(F, "$myfile") or die "Can't open $myfile\n";
while(<F>){
@info = split &quot;:&quot;;
$uname = $info[0];
@match = grep /^$uname$/, @names if (defined(@names));
print &quot;Duplicate user names: $uname @match \n&quot; if ($#match > -1);
push(@names, $uname);
}
 
Hi
How many time you are asking this question under different name?

Sachin
 
Patel - I'm wondering if these questions maybe *do* all come from different people, but maybe all on the same course.... Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
No Mike this is same person. &quot;nhelper&quot; then nhelper1. Looks like same pattern. But if I am wrong then sorry.

I don't mind answering/asking question.

Patel
 
Oh - I wasn't criticising you Patel - in fact these &quot;assignment questions&quot; where people just seem to copy-and-paste into tektips irritate my a little, I don't mind helping at all (like it) but resent being asked to do someone's assignment for them Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Oh ic.
Hi Mike, Don't worry in future even if you critice me. Bythe way I didn't even feel that you are criticicing. I really don't take most of the stuff personally. And I know if you critice me that might be good for me.

Patel

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top