Results 1 to 8 of 8
searching a file with wildcard characters in the search criteria
example: searching a property file abc.txt for getting a result string "heartbeat"
file contents as below:
heartbeat
hardbeat
nobeet
none
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-24-2009 #1Just Joined!
- Join Date
- Sep 2009
- Posts
- 8
[SOLVED] help with grep / egrep wildcard search
searching a file with wildcard characters in the search criteria
example: searching a property file abc.txt for getting a result string "heartbeat"
file contents as below:
heartbeat
hardbeat
nobeet
none
command executed is:
heart*
he*beat
*beat
all the above should print the result as heartbeat
Assuming many files like abc.txt are in the folder, the final command/shellscript should print matching results from all the files.
- 09-24-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 468
how about something like this:
cd /folder
grep heartbeat *
?the sun is new every day (heraclitus)
- 09-24-2009 #3Just Joined!
- Join Date
- Sep 2009
- Posts
- 8
- 09-26-2009 #4
Should think
would find it. Not an expert, the . may not be necessary. You could also haveCode:$ egrep "hea.*et"
if you knew it was the only word on the line. Using bot ^ and $ is overkill (copyright Pentagon).Code:$ egrep "^hea.*et$
It is highly instructive to make it colour what it has found: --colour ??
- 09-26-2009 #5Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
- 09-27-2009 #6Just Joined!
- Join Date
- Sep 2009
- Posts
- 8
Thanks guys
lugoteehalt and lomcevak
Thanks for your answers and explanation. Will try this and get back to you.
- 09-28-2009 #7Just Joined!
- Join Date
- Sep 2009
- Posts
- 8
Thanks alot, it works
I really appreciate your time answering this issue, it works like a charm.
I have another small issue left out, that is when I search for the search string if the result line has a \ at the end of line, I am not getting the text on the next line, which I need to show, is that possible?
- 09-29-2009 #8Just Joined!
- Join Date
- Sep 2009
- Posts
- 8
Found the soultion
Found it from a friend.
grep -A1 "heart.*at" prop.txt
Result:
----------
heartbeat \
more beats




