grep line that is start with 'int'

tommym121
tommym121 used Ask the Experts™
on
I like to use the 'grep'  to grep all line that starts with 'int' whether there is space, tabs in front of 'int'
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
more filename | grep int

Commented:
"|" is called the pipe sign
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
grep '^[   ]*int'  filename
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Commented:
LOL I think I spoke too early.

Did you mean int as in the datatype?

Author

Commented:
What I try to do is look for all line that int variable declaration line? So I need to find all integer variables declaration line.

so I have to be able to grep all these lines

int i ;
       int a;
\t\t    int b;

Commented:
do as I said earlier

more filename | grep int
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
there are two characters in the [ ], one is a space, ad the other is a tab

Author

Commented:
but I do not want to pick up  a line that contain 'int' in another word.
What I try to is to grep all the line with the word 'int' at the beginning of the line.
Most Valuable Expert 2014
Top Expert 2015
Commented:
grep -w '^[        ]*int'  filename

Author

Commented:
Great
Top Expert 2007

Commented:
or simply

grep -w int filename

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial