Edited by mirod: changed the title as suggested.
Hi,
I am trying to print the source line in C/C++ which ends with some numbers. I am receiving C/C++ files ending with some numbers. I can not compile those source. For ex.
Another file endno2.c/* file name is endno1.c */ * should*/ int i; 10002 /*should not*/ int j; /*should not*/ int k; /* should*/ int m; 20002
So I am trying to print those lines ending with nos. My code should be in single line. So I came out on unix machine like this:int i; int j; /* 10th line = 20 */ int k; /*should*/ int m; 20005
but it prints like thisfind . -name "*.c" -exec cat {} \; |perl -ne 'print $1\n" if $_ =~ /(. +*)\d+$/'
That is it matches entire line except the last character. My intention is to not to print those nos in the end. Then I have modified my code like this/*should*/ int m; 2000 /* should*/ int i; 1000 /* should*/ int m; 2000
But it does not print anything. If I remove the $ in the end, then it prints this line also which I do not want.find . -name "*.c" -exec cat {} \; |perl -ne 'print $1\n" if $_ =~ /(. +*)(.*?(?=\d))$/'
Can you pl. correct my regular expression. Again I want it to be in single line. My intention is to compile the code cleanly in C/C++ without those nos in the end. I am redirecting the output to a file and compile then. Thanks Ashok/* 10th line = 2 */
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |