The Daily Insight

Connected.Informed.Engaged.

general

How to check zero byte file in UNIX

Writer Gabriel Cooper

Check zero byte file in UNIX

The objective of the article is to discuss different methods through which you can find the zero bite file in UNIX.

Silky Terrier Dog Breed Playing Around
A zero byte file is a file that is empty it does not contain any data inside. Some of the examples where zero bites can be originated. 

Emails

Emails can be the source of zero byte files, sometime we received email with attachments that showed zero bytes of data. 

File downloading

During downloading if our network gets slow or due to an error if the file cannot be completely downloaded. It is also saved as a zero-byte file.

Name or extension of the file

Sometimes, due to the length of the file or its extension, the operating system could not support the file and it becomes corrupted. This is also caused by the creation of zero-byte file.

Self-creation of zero-byte file

In the UNIX system, the user has the right to create a zero-byte file. Mostly it’s created to provide extra information to the folder. 

Is Zero-byte file is contagious 

Many users think zero-byte file contain malicious errors, and that’s why they can be operated. Well, if you ask me, the probability is considerably low there is no compression software available that converts the whole data file in zero-bite. But we recommend deleting the files it can be corrupted. 

How to discover Zero-Byte File 

Method#1 

The GoldFynch case can be used to navigate the zero-byte files. The GoldFynch is an e-discovery simplifier. 

 

Method#2

Bash script is a shell script designed to run in a UNIX shell. 

Code

@echo off

set p_file=%1

set file

if not exist %p_file% goto no

for /f %%a in (%p_file%) do goto data

goto empty

:no

set file=no

goto end

:data

set file=data

goto end

:empty

set file=empty

goto end

:end

echo file=%file% 

Method# 3

If statement in bash 

*if [[ -s /x/y/z/file ]]; then* 

* …* 

*fi*