Ubuntu – Grep beginning of line

grepregexsedtext processing

I have a file with the following contents:

(((jfojfojeojfow 
//
hellow_rld
(((jfojfojeojfow
//
hellow_rld

How can I extract every line that starts with a parenthesis?

Best Answer

The symbol for the beginning of a line is ^. So, to print all lines whose first character is a (, you would want to match ^(:

  1. grep

    grep '^(' file
    
  2. sed

    sed -n '/^(/p' file
    
Related Question