LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How can I check wether a file is empty in Linux by using shell script programming ??? (http://www.linuxquestions.org/questions/linux-general-1/how-can-i-check-wether-a-file-is-empty-in-linux-by-using-shell-script-programming-150600/)

Bassam 02-26-2004 12:05 AM

How can I check wether a file is empty in Linux by using shell script programming ???
 
Hi Guys,
I through my shell programming I have a file that contains ping information, and I want to check every time whether the file is empty or not. I am using shell script programming.

my code is

So anyone can help me in this matter?


Code:

# Ping the node to check its availability
fping -A -r 1 -t 25 -u $OLD_LINE > /tmp/ping_dump.tmp

# Now how ro check whether the ping_dump.tmp file is empty or not ????


Thanks for the help

Bassam

druuna 02-26-2004 01:14 AM

Take a look at man bash and find the CONDITIONAL EXPRESSIONS section.

There a a lot of checks, you probably want the -s option.

if [[ -s ${somefile} ]]
then
<some commands>
else
< some other commands>
fi

Hope this helps

Bassam 02-26-2004 02:01 AM

Hello Druuna,
I posted another question to you regarding a previous support, Kindly, I want your support again, the question is on this link:

http://www.linuxquestions.org/questi...hreadid=138692


All times are GMT -5. The time now is 05:59 PM.