For each file in a directory, I wish to delete the last 57 lines and concatenate each result into a single output file. I have tried both
Code:
for fl in *.html; do head -n "$(($(wc -l < "$fl") - 57))" >> faq.html; done
for fl in *.html; do a=$(($(wc -l < "$fl") - 57)); head -n $a >> faq.html; done
with the same result in each case, the command hangs after producing an empty faq.html.
There is no complaint from the system, and the arithmetic expression produces the correct number of lines to copy from each file. Could someone kindly explain why this is failing?