awkgzipgunzip

Feed unzipped files from all subdirectories into awk


I want awk to process all files in unzipped form from all sub-directories.

This is what I've tried: It works only for top level directory files.

for file in *
do
    awk -v f="$file" 'NF > 0 {print f; nextfile}' <(gunzip -cf $(find . -type f) "$file")
done

(My goal is not to just print non empty file names using awk, I just gave this as an example)


Solution

  • Assumptions:

    One idea:

    while read -r file
    do
        awk -v f="$file" 'NF>0 {print f; nextfile}' <(gunzip -cf "$file")
    done < <(find . -type f)