bash multiple file operation
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 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? |
You are not giving the head command any input. In the head syntax, you either need a filename--or it will read from standard input. In your case it tries to read from standard input---and nothing is there, so it hangs.
Also, note that the head command can return the LAST N lines of a file---so you don't need that arithmetic. |
Quote:
|
All times are GMT -5. The time now is 08:17 AM. |