Marcos Griselli
Marcos Griselli

Reputation: 1346

Shell append order (>>)

exec 1>>${LOG}

I'm running some Shell scripts to check DB parameters. Its the same scripts that runes at 3 diferent times and generates a big log with each run output.

The problem is the order I need the big output to be in order as I run it. (First run = top of the file, 3rd run = bottom) And I'm getting this order 3rd - 1rst - 2nd o_o

Any advice?

Upvotes: 0

Views: 63

Answers (1)

dirkk
dirkk

Reputation: 6218

As it was suggested to post my comment as an answer I will obey... However, it is actually not much at all. You could execute your shell scripts and output to some tmp files, e.g. running separately

exec 1 >> ${LOG}.tmp1 
exec 1 >> ${LOG}.tmp2
exec 1 >> ${LOG}.tmp3

and them concatenate them

cat ${LOG}.tmp1 ${LOG}.tmp2 ${LOG}.tmp3 >> ${LOG}

You might want to delete the temp files after that

rm ${LOG}.tmp*

Upvotes: 3

Related Questions