Read a text file with bash
Im making a bash script and i need to check a text file to see if what someone entered is already there , if it is already there then i want the script to say you have already entered this are you sure? but im not sure how to do that can you help me please ,
thank you! |
You can use the grep command for that. For example
Code:
grep -q $USERINPUT textfile For more info on grep use Code:
man grep |
Quote:
|
Try putting it in your if statement ... you will be pleasantly surprised :)
|
Further note that in your future bash script, $? will return contain the return value of the last executed command.
OK |
Quote:
|
All times are GMT -5. The time now is 09:51 PM. |