Alibabacloud.com offers a wide variety of articles about linux shell scripting cookbook, easily find your linux shell scripting cookbook information here online.
1.7 arrays and associative arrays
An array is a very important part of Shell scripting, and it uses indexes to store multiple independent independent data as a collection. An ordinary array can use integers only as an array index, and associative arrays not only use integers as indexes, but they can also use strings as indexes. In general, it is easier to understand the use of strings for indexing.
/bin/psaux #输出当前进程详细情况 tip: From a programmer's point of view, the shell itself is a program written in C, and from the user's point of view, the shell is a bridge between the user and the Linux operating system. The user can either enter command execution or use shell scriptin
complex code that makes it difficult for developers to read and modify them.
Usually, its syntax and interpretation are not so flexible, and not intuitive.
Its code is usually not used by other scripts. The code reuse rate in the script is very low, and the script usually solves some very specific problems.
They generally do not support library features, such as HTML interpreters or processing HTTP request libraries, because libraries are generally only in the popular language and
Preface
Linux Shell Scripting Basics We are almost finished here, function believe that we are not unfamiliar with it, directly to the topic of it ~
Please indicate the original link:http://blog.csdn.net/u011974987/article/details/52718164This article is from: "Stromxu's blog" Body
After the last blog Shell function
T
LinuxIf command
WhateverProgrammingLanguage is inseparable from conditional judgment. Shell is no exception.If list thenDo something hereElif list thenDo another thing hereElseDo something else hereFi Ex1:#! /Bin/shSystem = 'uname-S' # obtain the operating system type.If [$ system = "Linux"]; then # If it is Linux, print the
standby.so it is necessary to make the user regret it once by scripting or other means. This article uses the Bash Shell script approach to this issue, and other solutions can be found at the end of the "reference". Script Writing IdeasSimilar to the idea of the Recycle Bin, the Recycle Bin has this feature: 1. not really deleted; 2. The same name can be, 3. Remember the source path of the file, as a scrip
Today see the system space is occupied, and then look at large files, found that Catalina.out has been >60g, there are many solutions online, but still want to learn to write a shell script to deal with, in this record to write content, as well as the problems encountered and processing methods.
Directly on the content:
First: VI, Touch command to create auto-clear-currday-catalina_out-content.sh files, do not forget to give executable permissions: ch
after the local opt-in file, you can view the file in the shared directoryIi. Crond Scheduled Tasks1, the background operation, to the scheduled time will be automatically executed, the premise of manually set the scheduled tasks in advance2. The scheduled tasks are divided into 2 categories (System level and user level)"System-level configuration file under Vim/etc/crontabPrint ASB at/tmp/test.log per minute as rootTailf–f/var/log/cron Dynamic View log (which task has been executed), you can d
I've been studying this Linux shell program recently because I'm interested in this Linux system, so I've learned the shell programming at once.In fact, this Linux shell programming is a summary of the execution of this overall co
From the programmer's point of view, the shell itself is a program written in C language, from the user's point of view, the shell is the user and the Linux operating system communication Bridge. The user can either enter command execution or use shell scripting to do more c
First, shell overview1.Shell Overview:Shell: Shell, a shell is a command-line interpreter that provides users with an interface-level program that sends requests to the Linux kernel to run programs, and users can start, suspend, stop, or even write programs with the
[Email protected] ~]# mkdir scripts; CD scripts[Email protected] scripts]# VI sh01.sh#!/bin/bash declaring shell names# program: Description of Procedure Content# This program shows the "Hello world!" in the Your screen.# History:# 2005/08/23 Vbird First release path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin main environment variable declarationExport PATHEcho-e "Hello world! \a \ n "Main program sectionExit 0 Execution Result
not 0.
#!/bin/bashCMD="echo test" #CMD为要执行的命令$CMD #执行命令if-eq0 ] #$?为退出状态then echo"$CMD executed successfully"else echo"$CMD executed unsuccessfully"fi1.12.4 passing parameters to a command
Commands in bash usually have multiple parameters, and the parameters of the command can be passed in different formats. Assuming that-p,-v is an available option, K n is another acceptable parameter, and you can accept a file name as a parameter, then several ways are equ
There are two types of Linux users in the world: adventurous and cautious.One type of user is always instinctively trying any new choice that can poke its pain points. They have tried countless window managers, system distributions, and almost all of the desktop plugins that can be found.Another type of user who finds what they like will continue to use it. They tend to prefer the default configuration of the system distribution used. The first skille
1. How Shell scripts work The Linux shell script is similar to Windows batch, but it has a lot more powerful features than Windows batch processing. The shell script is actually a stack of shell commands, with syntax such as shell
When using shell in Linux, arrays are occasionally used for convenience. The declaration method of the array is:
Array = (element1 element2 element3... elementn)
That is, wrap the array elements directly with parentheses, and separate the array elements with spaces.
The data is read as follows:
# Echo $ {array [0]}
The traversal of the array uses one to retrieve all:$ {Array [@]}
Complete example
Large data platform often set up to design multiple nodes of the cluster needs to be unified deployment, this design to the daemon or deployment script at different nodes, if it can be on the master machine, unified execution script, one-time start of the entire Cluster service, feel very nice. Because, share the following content:Prerequisites: Configure SSH password-free loginfor a simple command:If you are executing several commands on the remote node:SSH " cd/home; LS " Note the point:
When using the shell under Linux, the array is occasionally used for convenience. The array is declared in the following way:
array= (element1 element2 element3 ... elementn)
That is, wrap the array elements of the parentheses package together, and the array elements are separated by spaces.
Read the data as follows
#echo ${array[0]} #echo ${array[index]}
The traversal of the array takes a total of
+++++++++++++++++++++++++ +++++shell Foundation +++++++++++++++++++++++++++++++1. Shell overviewShell definition:The Shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux kernel to run the program, allowing the user to start, suspend, stop, and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.