Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Another Linux problem. Please help me.  (Read 6253 times)

0 Members and 1 Guest are viewing this topic.

Harlequin

  • Guest
Another Linux problem. Please help me.
« on: May 15, 2006, 01:10:48 PM »
The problem is that follows:
Construct a program (Shell script), called VERIF that asks for a name and verifies if it appears in other file called LISTING

I dont know how begin with this problem....

HARLEQUIN.

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Another Linux problem. Please help me.
« Reply #1 on: May 15, 2006, 02:25:14 PM »
man grep

man awk

Remember that all programs return an exit code which indicates their success or failure.

Good luck.
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

Harlequin

  • Guest
Re: Another Linux problem. Please help me.
« Reply #2 on: May 16, 2006, 08:12:55 AM »
Ok. Thanks for this clue. I will try doing something in that sense...

And I will tell you...

HARLEQUIN

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Another Linux problem. Please help me.
« Reply #3 on: May 16, 2006, 08:21:11 AM »
Actually, I should have said

info gawk

since the Texinfo page is much better than the man page, and the utility's proper name on Linux systems is usually "gawk" (Gnu awk).
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

Harlequin

  • Guest
Re: Another Linux problem. Please help me.
« Reply #4 on: May 16, 2006, 08:53:59 AM »
I just done it!!

the code is like follows:

user@linux> //(this is the prompt)
user@linux> cat > LISTING
James
Edward
Jhon
Peter
Paul
user@linux> //(and the file that contains the names is ready)

Now comes the shell script:

echo -n "Write a name: "
read name
if (grep -c $name LISTING) then
           echo "This name exists in LISTING file."
else
           echo "This name doesn´t exist in LISTING file."
fi

And this runs so fine....
Thanks very much Robpomeroy.... You have saved my life...
HARLEQUIN

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Another Linux problem. Please help me.
« Reply #5 on: May 16, 2006, 09:14:20 AM »
Well done!
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos