Special variables ($, $, $, $, $#, [email protected], $*)There are some special variables that can be used in shell programming. These variables can be used as global variables in the script.
Name
Description
$
Functions are often used when writing programs, and general development tools have a rich library of functions. But sometimes you need to customize the function to meet our needs.In Linux, the same is true for shell scripts, which sometimes use
Start the script under $hadoop_home/bin or $hadoop_home/sbin, the shell terminal will display the output information;Based on the output information, the information of Bash-x [Script-name] and the script itself can be used to locate where the error
1. Shell Variable TypeThe shell is a dynamic type language (not using explicit data declarations) and weakly typed languages (variable type operations vary according to requirements). The variables in the shell are non-typed (all string types), but
#!/bin/SHMyPath="/var/log/httpd/"MyFile="/var/log/httpd/access.log"#这里的-The x parameter determines whether the $mypath exists and has executable permissionsif[!-X"$myPath"]; Then mkdir "$myPath" fi#这里的-d parameter to determine if $mypath
Like other languages, the Shell can also contain external scripts. This makes it easy to encapsulate some common code as a standalone file.The Shell file contains the following syntax format:. FileName # Note number (.) With a space in the middle of
The test command in the shell is used to check if a condition is true, and it can be tested in three aspects of numeric, character, and file.
Numerical test
Parameters
Description
-eq
Equals is True
Data flow redirection is the transfer of a command that should appear on the screen to other places after executionStandard1, standard input (stdin): code 0, using or 2, standard output (stdout): Code is 1. , using > or >>3, standard error output
A test condition to judgeReturns a 0 exit state if the expression is true, or a non-0 exit state if the expression is false. Test has an alternative syntax, which is easier to read by enclosing the expression with parentheses "[]".1. string
This article mainly introducesShell8 Types of scriptsstringCutTakeThe method summarizes, each method gives the instance code and the operation result, at a glance, the need friend can refer to the nextstring truncation of Linux is useful. There are
First name the shell command as a. sh fileSave the above code as test.sh. and CD to the corresponding folder:chmod +x./test.sh #使脚本具有运行权限./test.sh #运行脚本Assuming an error/bin/bash^m:bad interpreter:no such file or directoryOne of the reasons for
Tag: Indicates a startup error system output mod writing preface inuxProcessPreface : A process refers to an instance of a running program . The new process consists of Fork () with the Execve () when the system call starts , and then run , know
Parameter unwinding (parameter expansion) is the procedure that the shell uses to provide variable values in a program.Expansion operators include substitution operators and pattern matching operatorsSubstitution operators
Operator
Reading slow, easy to forget, on the Internet to find examples to do, pondering the examples do not understand, and then continue to Baidu.The importance of shell scripts under Linux is not much to say. Starting with the first example:#!/bin/"Hello
Before you learn the regular expression, be clear and keep it in mind:In Linux, wildcards are interpreted by the shell, while regular expressions are interpreted by commands, so don't confuse them. Remember!!!usually have three text Processing tools/
Issue One: dos differs from windows in cmd On Windows systems, start-run-cmd can open "cmd.exe" for command-line operations. The operating system can be divided into the core (kernel) and shell (shell) two parts, wherein the shell is the operating
Ifs:A direct description of the usefulness of IFS, details of what ifs is doing ... Self GoogleFirst create a file of "a", and "a":Then we look at LS:--LSA a AIs this.Then if we need to write a script to manipulate each file:--For I in $ (LS); Do
In fact, this is very simple, in the Linux server installed plug-in Lrzsz can:Then, if you want to upload something in that directory, we can use the command RZ directly to solve the problem:Then enter:Select the file you want to upload, and the
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.