I would to like extract the pattern "/oracle" from a file.

I tried with "grep -w" command but it returned all the lines which have oracle word.

I need to extract only /oracle. Please tell me if any command grep,awk,sed gives my output

File Content:

  • are there lines without /oracle in them? can there be more than one match in a line? what if you have matches like /oracles? if you have -o option, try grep -o '/oracle'... else try sed -n 's#.*\(/oracle\).*#\1#p'
    – Sundeep
    Commented Dec 7, 2017 at 9:00
  • Yes ther are lines without oracle as well. No One match in a line.
    – Pandu
    Commented Dec 7, 2017 at 9:12
  • then you should change your sample data to include those other lines as well... and add complete expected output for clarity..
    – Sundeep
    Commented Dec 7, 2017 at 9:18

2 Answers 2


Try grep -x instead of grep -w:

$ grep -x "/oracle" test.txt

Tested on Linux, but should apply to HP-UX, too. Else look at the manpage for "line-regexp" (instead of "word-regexp").


I found a command in google and it worked perfectly.

awk "/^\/oracle$/" file_name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .