Sponsored Content
Top Forums Shell Programming and Scripting Identify empty file with null record Post 302976511 by RudiC on Thursday 30th of June 2016 05:41:56 AM
Old 06-30-2016
How about
Code:
case "$(wc -c <file)" in 0) echo empty file;; 1) echo file with null record;;  *) echo file with data;; esac

It would work on the given examples, but fail if a (non-*nix-text) file with a single character but without line terminator were encountered.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If statement falling over on a null record. Help please.

Okay i've got some code which reads a text file and loops through it and there a few if statements inside where one is failing (the one bolded). Basically the acc column contains a list of three digit access codes, some though have null records (i.e nothing in the field) so what I want to do is... (3 Replies)
Discussion started by: TonyR
3 Replies

2. Shell Programming and Scripting

identify the empty directories

Hi Wrote the below script to identify the empty directories ,when executing the below showing that directory is not empty but the directories are empty.Please help to identify the empty directories 33 is not empty 33 is not empty 33 is not empty 33 is not empty for file in `find .... (5 Replies)
Discussion started by: mohan705
5 Replies

3. Shell Programming and Scripting

How to check for null or empty string

Hi, I need to check for value not equal (<>) to 21 and not equal empty or null values. Please modify this script if then echo "$VALUE,$BSC_NAME,$BSC_ID" > $OUT_FILE/power_up.out end if TQ (5 Replies)
Discussion started by: doer
5 Replies

4. Shell Programming and Scripting

Table null is empty

hi I m executing a shell script in which records are to be fetched from a table. If the sql that is running empty result set it is displaying "table null is empty !". I dont want this msg on the standard output. COuld you please help me in this regard (3 Replies)
Discussion started by: priyanka3006
3 Replies

5. Shell Programming and Scripting

PHP: how can I delete empty/NULL elements from a multi-dimensional array.

Hi all I have a file that i'm running and exec(cat ./dat) against..and putting its contents into any array, then doing an exploding the array into a multi-dimension array... The 15 multi-dimensional arrays have elements that are null/empty, I would like to remove/unset these elements and then... (2 Replies)
Discussion started by: zeekblack
2 Replies

6. Shell Programming and Scripting

how to add empty filed to record

hi i have record looks like below 1,US I want to add empty field to the record as below 1, , , ,US how i can do it using awk ? i tried with awk its not working awk '{ print $1", ,"$2 }' filename > file 1 (2 Replies)
Discussion started by: raghavendra.cse
2 Replies

7. Shell Programming and Scripting

Identify Trailer record

Hello, My script has a trailer record(TR). Now I need to implement a logic, if TR is missed on the file it should generate me an email stating TR was not on the file.. Kindly help. (15 Replies)
Discussion started by: Harimalyala
15 Replies

8. Shell Programming and Scripting

awk to identify empty fields in line

I am trying to use awk to identify and print out records in fields that are empty along with which line they are in. I hope the awk below is close, it runs but nothing results. Thank you :). awk awk -F'\t' 'FNR==NR ~ /^*$/ { print "NR is empty" }' file file 123 GOOD ID 45... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

To find record having null value

Hi All My requirement is to find the null values in particular column of a file and reject it in case if it contains null values. But the challenge is that I want a common command which can be used across different file, as the position of the column we need to check for different file may get... (14 Replies)
Discussion started by: ginrkf
14 Replies

10. UNIX for Beginners Questions & Answers

Parsing null or empty output

I am working an some if then statements for a script. I want to be able to check for alpha characters or empty out put then exit out. if ]]; echo "Serial Number Invaild" then exit 3; How do I account if the output is empty or null in this in this statement. Many thanks (6 Replies)
Discussion started by: andysensible
6 Replies
ToDo(3pm)						User Contributed Perl Documentation						 ToDo(3pm)

NAME
Palm::ToDo - Handler for Palm ToDo databases. SYNOPSIS
use Palm::ToDo; DESCRIPTION
The ToDo PDB handler is a helper class for the Palm::PDB package. It parses ToDo databases. AppInfo block The AppInfo block begins with standard category support. See Palm::StdAppInfo for details. Other fields include: $pdb->{appinfo}{dirty_appinfo} $pdb->{appinfo}{sortOrder} I don't know what these are. Sort block $pdb->{sort} This is a scalar, the raw data of the sort block. Records $record = $pdb->{records}[N] $record->{due_day} $record->{due_month} $record->{due_year} The due date of the ToDo item. If the item has no due date, these are undefined. $record->{completed} This is defined and true iff the item has been completed. $record->{priority} An integer. The priority of the item. $record->{description} A text string. The description of the item. $record->{note} A text string. The note attached to the item. Undefined if the item has no note. new $pdb = new Palm::ToDo; Create a new PDB, initialized with the various Palm::ToDo fields and an empty record list. Use this method if you're creating a ToDo PDB from scratch. new_Record $record = $pdb->new_Record; Creates a new ToDo record, with blank values for all of the fields. "new_Record" does not add the new record to $pdb. For that, you want "$pdb->append_Record". SOURCE CONTROL
The source is in Github: http://github.com/briandfoy/p5-Palm/tree/master AUTHOR
Alessandro Zummo, "<a.zummo@towertech.it>" Currently maintained by brian d foy, "<bdfoy@cpan.org>" SEE ALSO
Palm::PDB(3) Palm::StdAppInfo(3) perl v5.10.1 2010-02-23 ToDo(3pm)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy