I am learning to use the grep command, so far so good but it is a little confusing... specially since I don't have a book and my only resouse is some websites. Any one has recommendations for books?
I am trying to search for 'aaa' or 'aaaa' or 'aaaaa', something with those characteristics... from lets say the /etc directory. I also want to add two lines of context before and after each keyword found.
I started doing this
Quote
Code:
[root@localhost ~]# grep x\{3,5\} /var
But I don't know where to put the spaces and if I am using the right character, I did this with no errors but I am not sure if I am doing it right.
Quote
Code:
[root@localhost ~]# grep x**\{3,5\**} /var
Now... what if I want to find multiple words, which is the AND command?
I learned the OR command [
Code:
Code:
root@localhost ~]# grep -nr 'gold\|silver'
What if I want to search for lets say : gold and silver and copper and diamonds and sand
Is this accepted?
Code:
Code:
grep -w '\<gold\ silver\copper\ diamonds\>'
Any clarification will help alot.
Thank you!