Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Getting same exit status for empty and non empty file Post 302264138 by mavesum on Wednesday 3rd of December 2008 08:09:04 AM
Old 12-03-2008
thnx for the reply , now i m giving like this

#!/bin/ksh
if [[ -s "$DD_INDD" ]]; then
echo "data"
ERROR=$?
echo "$ERROR"
else
echo "****************************"
echo "**** ERROR - FILE EMPTY ****"
echo "****************************"
ERROR=$?
echo "$ERROR"
fi;
exit

agaiin the same issue
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting the empty file

Hi, I have a TEST.dat file. As a clean up process, I have to delete the TEST.dat file if it is empty. Basically, I don't want to delete TEST.dat if it contains anything in it but want to delete TEST.dat if it contains any spaces or nothing in it. Is there a command to check if the file... (2 Replies)
Discussion started by: rkumar28
2 Replies

2. UNIX for Advanced & Expert Users

empty file in hp-ux

Hi, I need your help. How can I create an empty filename with a specific size, in hp-ux? Regards, Mizi (2 Replies)
Discussion started by: Mizi
2 Replies

3. Shell Programming and Scripting

File is not empty?

How do I check to make sure a file is not zero bytes? Something like: if then ????? (7 Replies)
Discussion started by: lesstjm
7 Replies

4. UNIX for Dummies Questions & Answers

how to find empty folders without using -empty

hi all: my solaris FIND does not support find myFolder -type d -empty how can i find the empty folders? thanks! (7 Replies)
Discussion started by: lasse
7 Replies

5. Shell Programming and Scripting

how to see if the file is empty or not?

hi how can I determine, if a file is empty or not?I am using read line clause. The script should be like: while read line do if(file is empty) then; ...... done < $blacklist (1 Reply)
Discussion started by: tjay83
1 Replies

6. Shell Programming and Scripting

while file is empty

how can i use while loop ? while file is empty do.... if not empty do ..... in bash (1 Reply)
Discussion started by: Trump
1 Replies

7. Shell Programming and Scripting

Grep for empty file

I have a program that takes a file in which I use a sed to remove some data that is not needed. If all of the data is removed. I want to grep for that in the file and print that there is no data left in the file. When I use sed, I replace a word with nothing but it still seems to leave a return... (5 Replies)
Discussion started by: plawr
5 Replies

8. Shell Programming and Scripting

Empty out the file

Hi All, I have a piece of perl code in which I DON'T want to delete a file rather empty out the contents, here is the code - if ( unlink("$opt_b") == 1 ) { print_log( "$opt_b deleted", 1 ); }else { print_log( "Could not delete $opt_b:$!", 1 ); ... (5 Replies)
Discussion started by: jacki
5 Replies

9. Shell Programming and Scripting

if/else with an empty file...

Hi there, I'm just starting out with shell scripting and I'm trying to make a test where the script will basically run yum check-update to find out if the server has any available and if it does it e-mails me but if not it will just stop there. I have it working if there are actually... (7 Replies)
Discussion started by: Imnewtothis
7 Replies

10. UNIX for Dummies Questions & Answers

find command on a empty directory - bad status

when I run the following command in AIX (bash), find ./* I get the following error. find: bad status-- ./* Thats becasuse, its an empty directory. The same works, when there the directory is not empty. Even though the find deesnt have to rerun any result. My full find command would look... (4 Replies)
Discussion started by: deepakwins
4 Replies
ATF-CHECK(1)						    BSD General Commands Manual 					      ATF-CHECK(1)

NAME
atf-check -- executes a command and analyzes its results SYNOPSIS
atf-check [-s qual:value] [-o action:arg ...] [-e action:arg ...] [-x] command DESCRIPTION
atf-check executes a given command and analyzes its results, including exit code, stdout and stderr. Test cases must use atf-sh(3)'s atf_check builtin function instead of calling this utility directly. In the first synopsis form, atf-check will execute the provided command and apply checks specified by arguments. By default it will act as if it was run with -s exit:0 -o empty -e empty. Multiple checks for the same output channel are allowed and, if specified, their results will be combined as a logical and (meaning that the output must match all the provided checks). In the second synopsis form, atf-check will print information about all supported options and their purpose. The following options are available: -s qual:value Analyzes termination status. Must be one of: exit:<value> checks that the program exited cleanly and that its exit status is equal to value. The exit code can be omit- ted altogether, in which case any clean exit is accepted. ignore ignores the exit check. signal:<value> checks that the program exited due to a signal and that the signal that terminated it is value. The signal can be specified both as a number or as a name, or it can also be omitted altogether, in which case any signal is accepted. Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. -o action:arg Analyzes standard output. Must be one of: empty checks that stdout is empty ignore ignores stdout file:<path> compares stdout with given file inline:<value> compares stdout with inline value match:<regexp> looks for a regular expression in stdout save:<path> saves stdout to given file Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. -e action:arg Analyzes standard error (syntax identical to above) -x Executes command as a shell command line, executing it with the system shell defined by ATF_SHELL. You should avoid using this flag if at all possible to prevent shell quoting issues. EXIT STATUS
atf-check exits 0 on success, and other (unspecified) value on failure. ENVIRONMENT
ATF_SHELL Path to the system shell to be used when the -x is given to run commands. EXAMPLES
The following are sample invocations from within a test case. Note that we use the atf_check function provided by atf-sh(3) instead of exe- cuting atf-check directly: # Exit code 0, nothing on stdout/stderr atf_check 'true' # Typical usage if failure is expected atf_check -s not-exit:0 'false' # Checking stdout/stderr echo foobar >expout atf_check -o file:expout -e inline:"xx yy " 'echo foobar ; printf "xx yy " >&2' # Checking for a crash atf_check -s signal:sigsegv my_program # Combined checks atf_check -o match:foo -o not-match:bar echo foo baz SEE ALSO
atf-sh(1) BSD
October 5, 2014 BSD
All times are GMT -4. The time now is 08:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy