How to concat rotated logs back together

Solution 1:

like this:

cat huali-access.log* > merged-huali-access.log

or to be sure its chronologically in order:

echo -n "" > merged-huali-access.log # creating new file and making sure its empty
for i in {1..52}
do
    cat huali-access.log.${i} >> merged-huali-access.log
done
cat huali-access.log >> merged-huali-access.log

Solution 2:

If the files have the correct modification times set (e.g. you did not copy them around without taking care of preserving the modification times), you can use

 cat $(ls -t huali-access.log*) > output.log

The -t option in ls will sort it by modification time.