Bash-Shell: If-Clause to check if file is empty

Hello,

I want to checkl whether my file has text in it or not.

 
if [ tmp_file eq ''" ]; then
...
 
if [ tmp_file != ''" ]; then
...

But none of these work
Can someone help me?

---------- Post updated at 09:00 AM ---------- Previous update was at 08:55 AM ----------

The code-tags caused an displayerror, so I rewrite without tags

if [ tmp_file eq ''" ]; then
...
if [ tmp_file != ''" ]; then
...

You can test if a file is empty with

if [ ! -s file ]; then ....

thank you, it works :slight_smile:

---------- Post updated at 10:05 AM ---------- Previous update was at 09:15 AM ----------

This code does not work:

 
if [ -s tmp_filter_0.$$ || -s tmp_filter_2.$$ ]; then
...

But the following does

 
if [ -s tmp_filter_0.$$ ]; then
...

or

 
if [ -s tmp_filter_2.$$ ]; then
...

So there is a bug in OR-condition, but I wonder what it is

Change the || to -o

try...

if [ -s tmp_filter_0.$$ ] || [ -s tmp_filter_2.$$ ]; then

thanks again :slight_smile: