Guest_imported
New member
- Jan 1, 1970
- 0
I have a 2 part question, still related to my other posts:
PART I:
i have a file database of variables in the form
var1:var2:var3:::
ex.
%celebrities.csh
michael jordan:basketball player:man::
britney spears:singer:woman::
madonna:singer:woman:::
---------------------------------------
looking at this code snippet:
echo -n "\nEnter a celebrity: "
set celebrity = $<
echo -n "Enter Job: "
set job = $<
if (`fgrep -c "${celebrity}" celebrity.csh`) then
(`fgrep -w "${celebrity}" celebrity.csh`) | fgrep ":man:" | awk -F: -f celebrity.csh '{printf "$3=%s", woman}'
else
echo -n "***Error*** No Celebrity by tht Name"
goto MainMenu
endif
-------------------------------------------------------
###i am trying to first check if the celebrity entered by the user is in my database (this works)
then
pipe the result of that line to another search that checks to see if that celebrity is a man (this also works)
then if true (is a man) pipe that into an awk command that would change the 3rd varible value in that database file (in this case "man" to "woman"
(this part is not working for me)
...so ex:
if user enter michael jordan, it performs a search to see if he is in the database file called celebrities.csh,
then checks to see if he is a man,
then should change the man variable to woman so if i looked at the celebrities.csh file it should look like this:
michael jordan:athlete:woman:: ##man status changed
britney spears:singer:woman::
madonna:singer:woman:::
i am not familiar with the awk utility and would like assistance in doing this please...
Also PART II:
using same database file, after having the user enter a celebrity, and do the search to see if they are in the database, how would i code i guess another awk command to remove that line that contains the entered celebrity from the database file??
---------------------------------------
looking at this code snippet:
echo -n "\nEnter a celebrity: "
set celebrity = $<
echo -n "Enter Job: "
set job = $<
if (`fgrep -c "${celebrity}" celebrity.csh`) then
##remove that matching line
else
echo -n "***Error*** No Celebrity by tht Name"
goto MainMenu
endif
-------------------------------------------------------
any help would be appreciated!
thanks,
jada
PART I:
i have a file database of variables in the form
var1:var2:var3:::
ex.
%celebrities.csh
michael jordan:basketball player:man::
britney spears:singer:woman::
madonna:singer:woman:::
---------------------------------------
looking at this code snippet:
echo -n "\nEnter a celebrity: "
set celebrity = $<
echo -n "Enter Job: "
set job = $<
if (`fgrep -c "${celebrity}" celebrity.csh`) then
(`fgrep -w "${celebrity}" celebrity.csh`) | fgrep ":man:" | awk -F: -f celebrity.csh '{printf "$3=%s", woman}'
else
echo -n "***Error*** No Celebrity by tht Name"
goto MainMenu
endif
-------------------------------------------------------
###i am trying to first check if the celebrity entered by the user is in my database (this works)
then
pipe the result of that line to another search that checks to see if that celebrity is a man (this also works)
then if true (is a man) pipe that into an awk command that would change the 3rd varible value in that database file (in this case "man" to "woman"
(this part is not working for me)
...so ex:
if user enter michael jordan, it performs a search to see if he is in the database file called celebrities.csh,
then checks to see if he is a man,
then should change the man variable to woman so if i looked at the celebrities.csh file it should look like this:
michael jordan:athlete:woman:: ##man status changed
britney spears:singer:woman::
madonna:singer:woman:::
i am not familiar with the awk utility and would like assistance in doing this please...
Also PART II:
using same database file, after having the user enter a celebrity, and do the search to see if they are in the database, how would i code i guess another awk command to remove that line that contains the entered celebrity from the database file??
---------------------------------------
looking at this code snippet:
echo -n "\nEnter a celebrity: "
set celebrity = $<
echo -n "Enter Job: "
set job = $<
if (`fgrep -c "${celebrity}" celebrity.csh`) then
##remove that matching line
else
echo -n "***Error*** No Celebrity by tht Name"
goto MainMenu
endif
-------------------------------------------------------
any help would be appreciated!
thanks,
jada