Learning bash notes-debugging shell programs and learning bash shell
In shell, the simplest debugging assistant outputs the echo statement. Many echo statements can be put into the code
Linux Bash Shell learning notes, bash learning notes
Parameter extension:
1. The parameter referenced by the name is called a variable.2. Parameters referenced by numbers are called positional parameters.3. Parameters referenced by a specific symbol have special meanings and
SHELL script strategy (learning notes) -- 1.5 bash environment configuration process, -- 1.5 bash
From the perspective of user login, shell is divided into two types:
Logon shell: If you log on through a terminal, use the su-usern
welcome message:/etc/issue,/ETC/MOTDWhen the terminal interface (tty1 ~ tty6) Landing, there will be a few lines of prompt stringThis information is written in/etc/issue more/etc/6.4 (Final) Kernel \ r on an \m
The meaning of each code within the issue
\d the date of the local end time;\l Display the first terminal interface;\m Display hardware level (i386/i486/i586/i686 ...) ;\ n Displays the network name of the host;\o display domain name;\ r operating system v
This article is also the second of the book note in Chapter 4 Basic shell programming of learning the bash shell 3rd edition, but we will not limit it to this.
String operation
In the following description, ":" Can be deleted. "Yes" means "exist but cannot be null". ":" means "exist ", this parameter can be left blank
to;$A-ne $B: is not equal;String test: The larger the ASCII value, the larger the value of the character comparison;"$A" > "$B": is greater than;"$A" "$A" = = "$B": is equal to;"$A"! = "$B": Not equal;-Z "$A": Empty, Empty is true, otherwise false-N "$A": not empty, not empty "true", Empty is "false"Note: You should use [[EXPRESSION]]File testing: The existence of test files and properties;-e $file: Exists or is true, otherwise "false";-a $file: ibid;-F $file: Whether the file exists and is a n
Positional variables (parameters)Position variable $1,$2,..../file_test.sh/etc/fstab/etc/inittab;$1:/etc/fstab; $2:/etc/inittab;shift: pops up the first argument in the argument list, which is equivalent to the shift popup in the array; Shift N: Indicates that n parameters are popped at a time, #判定: receives a parameter, if an existing file shows OK, if it does not exist, displays no Such file eg:$#: shows the number of parameters, $*: Parameter list [emailprotected]: parameter list; [[email
Linux learning record 4 (Bash and Shell scirpt), bashscirpt
1. What is Shell?
Shell in the narrow sense refers to the software for command columns, including basic Linux operation window Bash, etc.
used with variable names, and if the loop body does not include a variable name, a dead loop may occurHow the list is generated:1) Give a direct2) List of pure integersSEQ: Output An integer listseq [First [INCREMENT]] Last3) curly braces unfold{first.. Last}4) return value of the execution result of the command5) GLOBBING6) references to certain variables: [email protected], $*Features of the For loop:1. There is almost no cycle of death;2. The entire list needs to be loaded into memory during
Linux learning path: Understanding shell, bash, and shellbashI. shell
The direct controller of computer hardware is the kernel of the operating system. Because of the importance of the kernel, as a user, we cannot directly operate the kernel, therefore, we need shell to call
addition to Shebang, the # occupies the absolute beginning of the content, is the comment line, the interpreter ignores the contents of such a line;3. The explanation ignores all blank lines in the script;4. Lots of commands and keywords (if,else,then,do,while,for, ... )Note: Once the shell script runs in the current shell according to Shebang's instructions, an interpreter (child
:]] Practice :Copy all the files or directories in the/var directory that start with L, end with a lowercase letter, and have one digit in the middle to/tmpL*[0-9]*[[:lower:]]1, copy/etc directory with the beginning of P, with any characters in the middle, and the end of D files to the/tmp directory:2, copy the/etc/directory to start with P, the middle followed by 4 arbitrary characters, and the end of D files to the/tmp/a directory: If a does not exist, create it first3. Copy the/etc/directory
This article is the second chapter of "learning the bash shell" 3rd edition, command-line editing, Reading Notes. But we will not limit this.
In general, I just try to press it directly. If an error occurs, use the cursor and arrow on the left or right to modify the image, or use the upper/lower cursor to directly use the previous command or previous command to m
character classes is defined by the Lc_ctype categoryin the current locale.3. Example(1). Displays all letters beginning with the letter ending with all the blanks in the middle of the file:LS [[: Alpha:]]*[[:space:]]*[[:alpha:]](2). Displays all files that begin with any character, end with a number, with no spaces in the middleThe wrong wording:LS *[^[:space:]]*[[:d igit:]]In fact, the problem cannot be solved by using wildcards, and the problem needs to be resolved with regular expressions,
This article is the Reading Notes of customizing your environment, chapter 3 of learning the bash shell 3rd edition. Setting up a good user environment is crucial for our development. This section describes four aspects: special files, aliases, options, and parameters.
Special files
There are several special files in the user directory.Ls-
To view these hidden s
'] ' + echo CCCompare the next 5-6 lines can be found, the difference is to judge once, or judge two times4.2 String Judgments#!/bin/bash-xstr1= "ABC" If [-Z "$str 1"]; Then Echo ' str1 was empty ' else echo ' str1 is not empty ' fiprintf "\ n" str2= "" if [-N "$str 2"]; then Echo ' str2 I s not empty ' else echo ' str2 is empty ' fiprintf ' \ n ' If ["$str 1" = "$str 2"]; then echo ' str1 = str2 ' Else Echo ' str1 Note:-N is-not empty to deter
single quotation mark is just a special symbol for the value of a variable as the $ symbol within the double quotation mark itself. Using export, you can change a variable to an environment variable so that it can be used by more than one process, such as a child process. Use the unset command to cancel a variable. With the env command, you can view all environment variables, and the SET command can view environment variables and custom variables.Variables can be entered through the keyboard, d
) printf "restarting...\n" sub_stop sleep 1 Sub_start sleep 1 sub_status; status) Sub_status;; *) printf "Usage: $ {start|stop|restart|status}\n" exit 1;; Esacexit 0 This is a generic startup shell script, the main idea is to launch the specified application (the above code, the application to be enabled for Netty-sample, you can modify it yourself), the first to find the process ID, and then saved to the PID file, so that after the detection of the P
This article is part 3 of the fifth chapter of "Learning the bash Shell" 3rd Edition, Flow Control, but we will not limit this article. Flow control is a very common part of any programming language, including case. Here, we will continue to learn about them.
Case checks whether the string style matches and the number is equal to each other for different processi
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.