The Wayback Machine - https://web.archive.org/web/20240724193124/https://www.geeksforgeeks.org/difference-between-a-script-file-and-a-binary-file/
Open In App

Difference Between a Script file and a Binary file

Last Updated : 09 Dec, 2022
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report

In this tutorial, we will learn what a script file and a binary file are and what’s the difference between a Script file and a Binary file.

Binary File

A binary file is a file in which the content of the file is in binary format, the file data is not human-readable. Binary files contain formatted information that only certain applications or processors can understand. All executable programs are stored in binary files. For example, a jpeg image is a binary file designed to be read by a computer program only.

Script File

A script file is a file containing the sequence of instructions written in any scripting language that needs to be executed in order. In Linux or Unix systems a script file contains a sequence of Linux commands that need to be executed and if one of the commands in the sequence is not executed others will also not execute, the extension of a script file is generally .sh  in Linux. Below is an example of a script file in Linux that prints “Hello World”:

Script File in Linux

Difference between a Binary File and a Script File

S. No. Script File Binary File
1. A script file is a file containing a sequence of instructions written in any scripting language that needs to be executed in order. The binary file contains formatted information in a binary format that can only be understood by certain applications or processors.
2. It stores data using ASCII characters format. It stores data in binary format i.e. with the help of 0 and 1.
3. Error in a script file can be easily recognized and eliminated. Error in a binary file corrupts the file and is not easily detected.
4. It is human readable It is not human readable
5. It can be modified easily It cannot be modified by humans directly, it needs special software to modify them
6. It can be viewed using a text editor or any text viewer It needs specified software to view the binary file, for example, you need an image viewer to view the binary file of the image
7. It is written in High-Level Language It is written in Low-Level Language
8. Extension of shell script file generally: .sh, .csh, etc Extensions are generally: .bin, .dat

How to check whether a  file is a binary file or a script file?

  • Checking extension 
  • Using the file command

1. Checking extension

A shell script usually has the file extension .sh (Bourne or Korn shell) or .csh (C shell) whereas extensions of binary files are .bin, .dat. You can verify any file by just looking at the file extension, in the below image you can clearly see that dmyscipt.sh file has extension .sh hence it’s a shell script file and dlibex.dat has a .dat extension which is of the binary file hence it is a binary file, we will verify it by file command also in the below section.

 

2. Using the file command

file command helps in determining the type of the file and its data. The command doesn’t take the file extension into account instead, it runs a series of tests to discover the type of file data. 

file [option] [file name]

To find out whether the file is a script file or binary we used the file command on two different files to find out that, one file is a script file dmyscript.sh which is a Bourne-Again shell script file and another is a binary file which is present in /bin directory and the file command shows that it is a binary file, see the difference in the below output image:-

 

In this article, we hope you understand what is a binary file and a script file, what is the difference between them, and how to check whether it’s a binary file or a script file.


Similar Reads

Bash Script - Difference between Bash Script and Shell Script
In computer programming, a script is defined as a sequence of instructions that is executed by another program. A shell is a command-line interpreter of Linux which provides an interface between the user and the kernel system and executes a sequence of instructions called commands. A shell is capable of running a script. A script that is passed to
3 min read
How to write a shell script that starts tmux session, and then runs a ruby script
Scripts are important for streamlining workflows and automating tasks. One such way to streamline workflow is by using Tmux [Terminal Multiplexer]. When used along with shell scripts we will be able to automatically commence a Tmux session and perform certain tasks. In this article, we shall see how to use a shell script that will automatically sta
4 min read
Batch Script - How to check if a process is running via a Batch Script
Given a process or application (.exe) file, the task is to create a batch script that checks whether the process is running or not and output the same. Example: In this example, we have created a batch script by the name process.bat. We can easily check whether a process is currently running or not using the tasklist toolkit. Tasklist allows us to
2 min read
Difference Between Single and Double Quotes in Shell Script and Linux
Single quotes and double quotes are both functional in Linux while working with shell scripts or executing commands directly in the terminal but there is a difference between the way the bash shell interprets them. Single quotes: Enclosing characters in single quotation marks (') holds onto the literal value of each character within the quotes. In
3 min read
Shell Script to Show the Difference Between echo “$SHELL” and echo ‘$SHELL’
In shell scripting and Linux, the echo command is used to display text on the terminal or console. When used with the $SHELL variable, which contains the path of the current user's shell program, the output of the echo command can be different depending on whether the variable is enclosed in single or double quotes. echo "$SHELL" will expand the $S
4 min read
Shell Script to Delete the Zero Sized File Using If and For
There are many files in our system which are of no use for us as temporary files. So we need to clear all those files, but it is very hectic to find each file and delete them. Here we will create a script that will automatically search for the zero-sized file and delete them all. Before starting, we will see how to search for directories. Searching
2 min read
Shell Script to Count Lines and Words in a File
Linux provides users a great cool feature of the command-line tool along with a graphical user interface where they can perform tasks via ruining command. All of this command returns a status according to their execution. Its execution value can be used for showing errors or take some other action in a shell script. There may be some scenarios wher
6 min read
Shell Script to traverse all internal URLs and reporting any errors in the "traverse.errors" file
If you are using a web server or are responsible for a website, either simple or complex, you probably find yourself doing certain tasks with high frequency, significantly identifying broken internal and external site links. Using shell scripts, you can create many of these tasks, as well as other normal clients/server functions such as managing ac
2 min read
Shell Script to Display All Words of a File in Ascending Order
Here we will see a shell script that will arrange all the words from a file in ascending order, which comes in handy when we have many words that need to be sorted in ascending order. The script helps to analyze the data easily and represent it in a much more organized manner. Approach: Store the value of the file into a filename variable.Store the
2 min read
Shell Script to Put File in a FTP Server
The File Transfer Protocol also called FTP is used to transfer files from client to server and vice-versa. It mainly uses port 21 for communication. Here we can simplify the process of uploading files using FTP. But, before we write a script, let's look at how to get/put files onto an ftp server directly using commands. Basic FTP Command: The comma
4 min read
three90RightbarBannerImg