Linux command to delete empty fastq.gz files
1
0
Entering edit mode
11 weeks ago
twangxxx • 0

Hi all,

I am wondering how to use Linux command to remove all the fastq.gz files within a folder.

As the compressed fastq.gz has a size of 20 bytes even if it's empty after decompressing, I am not sure how to delete (and list) them.

I tried to list them when I was in the folder - but somehow find . -size 20 returned nothing. However, ls -l did tell me there were a bunch of size 20 fastq.gz files.

Here is an example of a set of "empty" fastq.gz files:

 gzip --list xxxxxxx.gz
compressed        uncompressed  ratio uncompressed_name
20                   0   0.0% xxxxxxx.fastq


Thank you so much!

linux fastq gz • 301 views
0
Entering edit mode

I think you are missing c option for bytes.

$find . -type f -name "*.gz" -size 20c -exec rm -i {} \;  If you want to remove any file of size 20 bytes and under try: $ find . -type f -name "*.gz" -size -20c -exec rm -i {} \;


To be safe, please filter by file extension and use -i after rm.

0
Entering edit mode
11 weeks ago

You could use the - flag to get files smaller than a small size, for example for 20 bytes:

find . -size -20c


will give you all files smaller (-) than 20 bytes (c).