i have a huge .java file and i want to find all declared objects given the className. i think the declaration will always have the following signature:
className objName;
or
className objName =
or
className objName=
can someone suggest me a grep pattern which will find these signatures. I have the following (incomplete) :
cat $rootFile | grep "$className "
EXAMPLE :
If the input file is :
Policy pol1;
Policy pol2 ;
Policy pol3 ;
Policy pol4=new Policy();
Policy pol5 = new Policy();
Policy pol6= new Policy();
I want to extract the following list :
pol1
pol2
pol3
pol4
pol5
pol6
cat. Bothgrepand Perl (used in an answer below) accept filenames as arguments. Also,grepis not part of Bash so there's no such thing as "bash grep".