LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-25-2004, 11:05 PM   #1
Bassam
Member
 
Registered: Mar 2003
Location: Malaysia
Posts: 63

Rep: Reputation: 15
Question 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
 
Old 02-26-2004, 12:14 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
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
 
Old 02-26-2004, 01:01 AM   #3
Bassam
Member
 
Registered: Mar 2003
Location: Malaysia
Posts: 63

Original Poster
Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about shell-script programming GSX Programming 11 11-22-2005 04:58 PM
Replacing a particular position in a file thru shell script in Linux sgracelin Programming 7 06-22-2005 07:04 AM
[c shell] file empty? saiz66 Programming 1 09-28-2004 10:57 PM
How to delete a line from a text file with shell script programming Bassam General 1 01-28-2004 08:51 PM
shell script programming steltner Linux - General 0 05-17-2003 07:00 AM


All times are GMT -5. The time now is 06:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration