search for key word from a file
I have writing a ksh and basically, I want to reach for a file (output.tst) and seach for the key word "MYDB"
Code:
if [[ -n `ls $log/output.tst | grep "MYDB" | grep "ASH"` ]] ; then doesn't seem to work, what did I do wrong. Thanks all. |
I don't know. Can you do a example?
What must out the if condition? |
Sorry, I've just seen this and it confuses me -- what does this do?
Code:
ls $log/output.tst |
sorry if I confused you.
Basically, I want search for the file and look into the file to make sure those two key words are there. |
grep -i "word" file ?
look into REGEX as well, that will help out. |
Quote:
Code:
ls log/output.tst Code:
output.tst Code:
cat log/output.tst | grep "MYDB" |
grep would return:
oracle 12689 1 0 Sep05 ? 00:00:09 MYDB how can I trim everything so I get only "MYDB"? thx |
If you find out let me know, I need o dabble in scripting too.
|
how can I search for the string within a file?
Code:
if [[ -n `ls $log/output.tst | grep "MYDB"` ]] then |
MYDB$ $ should look for " " at the end of a string. If I remember correctly.
|
sorry, I don't get it......
|
Quote:
Code:
ls log/output.tst | grep "MYDB" Code:
ls log/output.tst Code:
output.tst |
The $ should go at the end so it searches for MYDB. So grep MYDB$ would search for strings ending in MYDB. You can "man grep" for more rules for it.
|
Quote:
|
hmm I might not be on the same page as you, i kinda understand what you are asking, but I'm new to this as well, so if i've thrown you off track sorry ;)
|
All times are GMT -5. The time now is 09:19 PM. |