The problem of the -p flag is, that the input stream is read line by
line. Then the regex /.*(?=package)/ will only be applied to one line.
But I want to remove all lines before the line starting with "package".
See the following example:
/**
* header
**/
package test;
...
The result of the replacement looks like this:
/**
* foo.bar
**/
package test;
...
If I use the one-liner at the top of the message with an input like
'test/Tes*.java' then the ARGF stream does somehow not differ between
the different files.
The problem of the -p flag is, that the input stream is read line by
line. Then the regex /.*(?=package)/ will only be applied to one line.
But I want to remove all lines before the line starting with "package".
See the following example:
/**
* header
**/
package test;
...
The result of the replacement looks like this:
/**
* foo.bar
**/
package test;
...
If I use the one-liner at the top of the message with an input like
'test/Tes*.java' then the ARGF stream does somehow not differ between
the different files.
It sounds like you might want -n rather than -p. -n does the same
loop, but without printing. You could arrange to print once you've hit
/package/.