I wrote the following script:
for filename in `find . -name '*'.cpp | grep $IN_REGEX | grep -v $OUT_REGEX` do echo "Output file is $OUTPUT_FILE" count=`git log --pretty=format: --name-only $filename | grep -v ^$ | wc -l` echo "$count $filename" >> $OUTPUT_FILE done
But nothing gets written into the output file.
Please note:
- I have set the values for
OUTPUT_FILE
,IN_REGEX
andOUT_REGEX
. - The code inside the loop is being executed. I checked this with an
sh -x
invokation. - When I remove the
>> $OUTPUT_FILE
I get the output. - I tried a
touch $OUTPUT_FILE
inside the script and that is working fine.
Can someone please point out what is my mistake here?
Best Answer
Does $OUTPUT_FILE exist? What are its permissions (
ls -l $OUTPUT_FILE
,getfacl $OUTPUT_FILE
)? How many times is theecho "Output file..."
executed? (I'd put that one outside thefor
, but it's your call)?(I'm suspecting your
find ...
pipeline doesn't return anything)