I'm looking for a command which removes files having 0 byte of having only header line (1 line).
My ETL process generates these files. Few files are not having header, in that case if no data from source, it will be 0 byte and few files are having header, in that case if no data from source, it will generate a byte with header information only, but no data.
I found the command to remove file with 0 byte
find . -type f -size 0 -exec rm {} \;
But not able to find command to remove file having only one line (header). I tried below command, but it is not working
find . -type f -size 0 -exec rm {} \;
I need it in form of command, as I do not want to create shell script to run at the end of ETL process
find /path/to/files -type f -ctime -1 |
while read fname
do
sz=`cat $fname | wc -l` # Not a UUOC done to get just a line count
[ $sz -lt 2 ] && rm $fname
done