How can I check if a file is empty?

后端 未结 4 2179
春和景丽
春和景丽 2021-02-18 18:51

I have thousands of text files and would like to know how to check if a particular file is empty. I am reading all the files using this line of code

Y<-grep(\         


        
4条回答
  •  萌比男神i
    2021-02-18 19:46

    find . -empty 
    

    or

    find . -empty |awk -F\/ '{print $FN}'
    

    If you want to limit just txt files:

    find . -empty -name "*.txt"
    

    If you want only asci files (not just .txt)

    find . -empty -type f
    

    put it all together:

    find . -empty -type f -name "*.txt" |awk -F\/ '{print $NF}'
    

提交回复
热议问题