Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the linux shell scripts?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you about the linux shell script, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Shell is a command interpreter between the kernel and the user, which is responsible for transmitting the user's instructions to the kernel and echoing the execution results to the user. Shell is a program written in C language, and it is a bridge for users to use Linux. At the same time, Shell can also be used as a powerful programming language.

What we often say Shell means command line interpreter and a shell on the kernel. Several common types of Shell include script support provided by sh, csh, bash, zsh and so on.

Shell was born in Unix and is a script programming that interacts with Unix/Linux. It is meaningless to learn Shell alone. Students with Linux foundation should know that Linux integrates Shell environment by default, and the function point of Shell lies in the use of external commands.

Its internal data processing

It focuses on text (or string, or character stream) processing, while the native processing of operations and other basic data structures (such as array, set, map, etc.) is weak, and the functional goal is to automate commands.

However, while realizing command automation, Shell needs to rely on other programs to complete most of its work, which is its defect and an advantage, but its indisputable advantage is its concise scripting language markup, and it executes faster and more efficiently than programs written in C language.

So if we have friends who do operation and maintenance or even basic management of Linux servers, as long as we learn Shell programming, we can greatly save our time and manage our servers more quickly.

Bash is the default Shell of the Linux standard and an acronym for BourneAgainShell, because bash has many features, such as: you can use functions similar to doskey under DOS, use the arrow keys to look up and quickly enter and modify commands. Automatically give a command that begins with a string by looking for a match

In addition, bash contains its own help function, you only need to type help at the prompt to get relevant help, in the Linux system we often see the contents of the file beginning with: #! / bin/bash, which declares that the file is a bash-based Shell programming file.

There is a program like this:

We know that calculations are executed one by one when executing instructions. Then it is easy to understand the above three lines. The purpose of the sequential operation is to enter the mongodb/bin directory, then execute the startup mongodb data and save it as m.sh, so that as long as we execute a line in the Linux terminal: shm.sh, enter, the calculation will execute the instructions in turn to achieve the function of starting the mongodb database.

So we need to execute more instructions, okay? The answer is yes, if we need to execute hundreds of lines of instructions and execute them separately, we have to repeat the operations, then write them into a Shell in turn, so that it is very convenient to execute them. During the execution of Shell, we can record the result reports of some nodes by > or > >.

For example, a shell:

The practical problem to be solved by this Shell is to extract all the compressed packages in the lamp directory in batch, so that we can see that the result set of ls can be used to participate in the execution of the next instruction.

So now we have a need to change all the uppercase letters in the names of files under a certain folder to lowercase letters, if we have to change them one by one manually, but it is painful to find files. At this time, Shell has played a powerful role.

In this way, a complex operation is well solved.

Sometimes when we manage files, we need to delete all empty files and useless files.

These are the linux shell scripts, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report