I have various java files that have the following statement in their methods:
var1.setMaximumSize((-1));
The statement starts with 6 white spaces.
I am trying to delete these lines or replace them with an empty string. I have tried the following script with no success:
for fl in *.java; do
mv $fl $fl.old
sed 's/^\s*var[0-9]+\.setMaximumSize\(\(-1\)\);$//g' $fl.old > $fl
rm -f $fl.old
done
Many implementations of sed do not accept modern regex patterns. The ones that might be problematic in your expression are \s and +. (Try \+). Also, sed treats ( as a normal character which must be escaped to become a meta character. You could try: