![]() |
A .sh file is a scripting language command file containing a computer program that can be run by the Unix shell. It can contain a series of commands that run sequentially to perform operations such as file processing, program execution, and other similar tasks. These are run from the command line interface by the user or in batch mode to perform multiple operations simultaneously. Script files can be opened in text editors such as Notepad, Notepad++, Vim, Apple Terminal, and other similar applications on Windows, MacOS, and Linux. Brief HistoryThe .sh file extension is often associated with shell scripts, particularly those written for Unix-like operating systems. It originated with the development of Unix in the early 1970s. Stephen Bourne developed the original Unix shell, known as the Bourne Shell (sh). It became the default shell on Unix systems and included a scripting language for automating tasks. Users can begin creating shell scripts by writing a series of shell commands in a text file. It is still a fundamental component of Unix-like operating systems and is used extensively for a variety of scripting tasks, including automation and system administration. On many systems, Bash has emerged as the factory standard for shell scripting. Here are some key points about shell scripts and .sh files:
SH File Format
Here’s a simple example 1 of a Bash script:
How to run the .sh fileTo run this script, you would save it to a file, make it executable (chmod +x script.sh), and then execute it (./script.sh). Output of the following code
Example 2
Save this code in a file with a .sh extension, for example, greeting.sh. To make it executable, run the following command in the terminal:
Now you can execute the script:
Output
ConclusionAt last, we can say that shell scripting languages are widely used by developers when they are working directly with the operating system using the command line tools. That will help you to automate the many tasks that otherwise require human input which will increase the resource cost. |
Reffered: https://www.geeksforgeeks.org
File Formats |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |