Unix to verify file has no content and empty lines
Your file might have new line character only.
Try this check:
[[ $(tr -d "\r\n" < file|wc -c) -eq 0 ]] && echo "File has no content"
A file of 0 size by definition has nothing in it, so you are good to go. However, you probably want to use:
if [ \! -s f ]; then echo "0 Sized and completely empty"; fi
Related videos on Youtube
iaav about 1 year
How to verify that a file has absolutely no content. [ -s $file ] gives if file is zero bytes but how to know if file is absolutely empty with no data that including empty lines ?
$cat sample.text $ ls -lrt sample.text -rw-r--r-- 1 testuser userstest 1 Jul 31 16:38 sample.text
When i "vi" the file the bottom has this - "sample.text" 1L, 1C
Kent over 10 yearscan you give an example a file with 0 byte, but with content (including empty lines) in it?
Ansgar Wiechers over 10 yearsA file with 0 bytes size couldn't possibly contain empty lines. An empty line consists of exactly one character: a line-feed. A file containing at least one empty line must thus be at least 1 byte in size. That is what @Kent was hinting at.