Computer Hope
Software => BSD, Linux, and Unix => Topic started by: Harlequin 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.
-
man grep
man awk
Remember that all programs return an exit code which indicates their success or failure.
Good luck.
-
Ok. Thanks for this clue. I will try doing something in that sense...
And I will tell you...
HARLEQUIN
-
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).
-
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
-
Well done!