|
How to check for zero byte file in UNIX?
I want to check whether if a file is a zero byte. in if else condition Which option should I use? is it -s or -z -- is this a valid option Cannot find that in unix man for IF Solution: I always use -s ... *if [[ -s /x/y/z/file ]]; then*
Always works. or See man page of bash(see below) -s file
-z string
-s for file size -z for string size or You can man test instead of if -s file True if file exists and has a size
-f file True if file exists and is a regular
File exists and is zero byte if [[ -f $file ]] && [[ ! -s $file ]]; then
|
|
See Also
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|