LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2005, 10:00 PM   #1
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Rep: Reputation: 15
How to Check to see if a file has Null Data


Here is my problem:

I am running a remote mysql query which will either return a value or will not. If it does not, I would like to execute a few commands. I tried running the query and checking what $? was, but it seems to always be 0. I was going to dump the output of the query into a file and check to see if the file contains NULL data or not. How can i do this? Or is there a better way?

Thanks!
farmerjoe
 
Old 03-13-2005, 10:05 PM   #2
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Original Poster
Rep: Reputation: 15
I guess i could just check and see if the file has a size of 0 or not, I just figured there must be some command to check.

-farmerjoe
 
Old 03-14-2005, 05:37 AM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
look at these:
$ help test
$ man test
$ man grep

$ grep NULL dumpfile
$ echo $?
1
$ test -s dumpfile
$ echo $?
0
$
grep NULL: does the file contain null? (1 -> no)
test -s: is the file non-empty (0 -> yes)

Hope this helps,

Jonas Kölker
 
Old 03-15-2005, 02:43 PM   #4
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Original Poster
Rep: Reputation: 15
Ahh that was very helpful! Thanks!

-farmerjoe
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LILO and BIOS Data Check jrdioko Linux - Software 1 05-03-2009 05:28 PM
What applicability of a file /dev/null ukrainet Linux - Newbie 1 12-01-2004 09:04 AM
how to check the data transfer of multicast protocols abirami Linux - Networking 1 09-05-2004 02:26 AM
gtk+ dialog, data check before close danxl Programming 1 10-11-2003 11:29 PM
replace null characters in a file Philipp Programming 2 09-20-2001 02:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration