1

I need to save the output for each command inside the for loop. My code is given below but it is not saving the log files.

count=60
for d in /afs/cern.ch/user/r/rasharma/work/TBA/Data/Run06*
do
        echo $d
        echo "./shrd51_EventBuilderVFAT.sh $d"
        ./shrd51_EventBuilderVFAT.sh $d | tee $count_EventBuilder.log
        echo "./shrd51_TrackFinder.sh $d"
        ./shrd51_TrackFinder.sh $d | tee $count_TrackFinder.log
        echo "./shrd51_Analyzer.sh $d 0$count"
        ./shrd51_Analyzer.sh $d 0$count | tee $count_Analyzer.log
        count=$((count+1))
done
4
  • 2
    Use tee -a to append. Commented Aug 13, 2014 at 6:55
  • And if you are appending, you may want to clear out (empty) your files at the start of the script somewhere with > file Commented Aug 13, 2014 at 7:08
  • @thatotherguy not working. And I don't need to append. Whenever I will run this I need to recreate a new file. Commented Aug 13, 2014 at 7:34
  • @MarkSetchell I don't need to append. Also I tried ">" instead of "| tee" but it didn't worked. Commented Aug 13, 2014 at 7:35

1 Answer 1

6

The issue is that $count_Analyzer.log is expanded like ${count_Analyzer}.log, that is, the value of the variable count_Analyzer followed by the string .log. Since that variable doesn't exist, you'll have a hidden file .log with all the output.

You want ${count}_Analyzer.log.

Good luck finding particles!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.