I have one doubt with this:
for i in ./*.gz do gunzip -c $i | head -8000 | gzip > $(basename $i) done
I get an "unexpected end of file" error for gzip, and I don't get the 8000 at all, only a few tens of lines. I've checked the integrity of my files and they are fine. Curiously, if I run for individual files:
gunzip -c file1.gz | head -8000 | gzip > file1.gz
I get the expected result. With this script I can obtain the first 8000 lines from a compressed file with 10708712 lines, and compress again. The new file overwrites the original file, but that's ok.