The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 07:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 07:12 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-23-2006
Registered User
 

Join Date: Feb 2006
Posts: 1
Question AWK problem

Sir,
I'm new to awk programming, i have been stuck in a problem could you plz clear that for me.

$ who > file1 #(say)

$cat file1 (enter)

uf146 xyz 1234
ge001 mmbm 999
mgu155 ooo0 7yh
ge101 unix 1234

$vi awk1.prog

awk -F " " ' BEGIN {
print " Enter the user name " ;
getline name < "-" ;
}

{
while(name~$1)
{
print $0; # complete record
exit;
}
}' file1

output:

$bash awk1.prog
Enter the user name : mgu155

ge101 unix 1234

$bash awk1.prog

Enter the user name : ca123

???? when no user ??? no output ??? // what we should do to promt no user exists

-ANAND
Reply With Quote
Forum Sponsor
  #2  
Old 03-23-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
seems that you have posted under the wrong umbrella ...

try this,
Code:
nawk -F " " ' BEGIN { line=""; i=0; print "enter name: " ; getline name < "-"; }
{ 
  while(name~$1)
  {
    i=1;    
    line=$0;
    break;
  }
 }
END {
 {
    if( i > 0)
    {
      print line;
    }
    else
    {
      printf "%s not found\n", name;
    }
  }
}' file1
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0