Learning and using bash shell shortcuts
By fenng|It can be reproduced. During reprinting, it must be indicated by a hyperlink.ArticleSource and author information and copyright notice Web: http://www.dbanotes.net/techmemo/shell_shortcut.html
This articleBASH Shell shortcuts. It is worth
variable that is only valid for code snippets within a function locally a=1title: Bash xxxx.SHInput-T5represents a triangle with 5 lines of paint-L7represents a draw slash 7 lines #!/bin/Bashtriangle () { forXinch$(seq 1$1) Do forYinch$(seq 1$(($1-$x))) Do Echo-N" " Done forZinch$(seq 1$((2* $x-1))) Do Echo-N"" DoneEcho Done}line () { forIinch$(seq 1$1) Do forXinch$(seq 1$
This article is also the fifth chapter of "Learning the bash Shell" 3rd Edition, Flow Control, 4 of Reading Notes, but we will not limit it to this. Flow control is a very common part of any programming language, including case. Here, we will continue to learn about them.
The select statement is different from other flow control statements. There are no similar s
The/etc/passwd file contains a list of all system user accounts and basic configuration information for each userUser name: Password: uid:gid: User's full name: User's default working directory: User Default shell programBy default, the bash shell automatically processes commands in the. bashrc file under the user's home directory when it starts.It often sets the
number2. Settings and references the first way to set up: references: [[email protected]~]# a[0]=1 Echo${a[0]} [[email protected]~]# a[1]=2[[Email protected]~]# a[2]=3Subscript starting from 0, 0 represents the first second setting: [[email protected]~]# b=(a b c) [[email protected]~]#Echo${b[0]}a[[email protected]~]#Echo${b[1]}b[[email protected]~]#Echo${b[2]}c[[email protected]~]# b= (a B c [ -]=carol)--You can skip a few elements directly to the 51 assignment [[email protected]~]
This article is also the fifth chapter of "Learning the bash Shell" 3rd Edition, five of Flow Control's reading notes, but we will not limit it to this. Flow control is a common part of any programming language, including while and util, which are also common in advanced programming languages. Here, we will continue to learn about them.
The while and util syntaxe
This article is also the seventh chapter of "Learning the bash Shell" 3rd Edition, "Input/Output and Command-Line Processing", four of the Reading Notes. Our goal is to read books thin. We will examine how the Linux system parses bash.
Step 1: The command is assigned as a token based on spaces, tabs, NEWLINE,;, (,)
Historical command History-C Clear-W Write ~/.bash_historySave 1000 By default, can be modified in /etc/profileCall TAB completioncommands, directories, files
Command aliasesAlias aliases = ' Original command 'Command execution order:Absolute path or relative path > alias > Bash's internal command > The first command found in $PATH environment variable (external command)Configuration file:/ROOT/.BASHRCDelete: Unalias aliasesCommon shortcut keys
Input and output redir
Here is an example of a simple tag, throw this question, and then add the complete.The parsing order of bashExample:[Email protected]:~/sh_test$ sudo awk ' nr==1 {print $} '/etc/shadowRoot:!:16141:0:99999:7:::[Email protected]:~/sh_test$ sudo awk ' nr==1 {print $} ' -bash:/etc/shadow: Insufficient AuthorityWhy does the above command 2 add a file input to the redirect and there is not enough permission. Cause: Add Linux
device, you cannot uninstall the device fileThe lsof command can obtain process information for using a device file, stop the process, and then uninstall the device fileDfUsed to view the usage of all mounted disksThe Linux system has a process in the background that processes files or uses files. The output value of the DF command shows the current value that is considered by the Linux system. It is possible that a running process on the system has created or deleted a file, but the file has n
Write a second shell script today and write the after-class questions in "private cuisine". The problem needs to write a check whether a name exists, does not exist to create a file, there is a need to determine whether the name of the file, the file is deleted after the creation of a directory with the same name, if the directory is to delete this directory.First set up a basic condition: The Operation directory is/tmp/test/(note: If this directory d
Label:Lvy Teacher Teaching Program, as well as a substitute shell part of the course, we all feel that the teacher does not work, the operation of the class is wrong, I think her foundation is not good. Moreover, she could not explain the reason, the student asked why, she did not know. Crash. To the XX training institutions after the reaction, said the teacher project experience, but if a person foundation is not, do more projects also no use Ah, all
have an error message in your script, you can redirect a separate line of output to stderr. All you need to do is redirect the output information to the stderr file descriptor using the output redirection character. When redirecting to a file descriptor, you must precede the file descriptor number with a :echo "This was an error message" >2 Permanent redirection: Use the EXEC command to tell the shell to redirect a specific file descriptor during the
-b. Specifies the small file size.-lSpecifies the number of small file rows.PREFIXprefix for small files. The ability to optionally specify a string that is defined for itself.
14, Xargs
xargsRead the standard input, separated by a space or line break, separate the standard input into multiple parameters, and then run the specified command, such as the following:
command
For example, the following command,/tmpunder the folder to findcorethe name of the file,
/hostname/histsize, etc.)You can see it in the/etc/profile.Read/etc/profile.d/*.sh (color language instruction alias)~/.bash_profile,~/.bash_login,~/.profile (only one of them can be read sequentially)~/.BASHRC (called in ~/.bash_profile),/ETC/BASHRC (called in ~/.BASHRC)Any one read succeeds and no longer reads the nextThe respective home directories are only valid for eachAfter the modification succeeds, source reloads the scriptNon-loginA shell tha
[[: Lower:]] all lowercase characters[[: Upper:]] all uppercase characters[[: Alpha:]] all uppercase and lowercase letters[[:d Igit:]] All numbers[[: Alnum:]] numbers and uppercase and lowercase[^] matches any single character outside the specified rangeExample #ls[[:alpha:]]*[[:space:]]*[[:alpha:]], displaying a file that starts with a letter and ends with a letter and contains spaces in the middleThe type of shell that stands in terms of user loginL
Login:
Bash executes/etc/profile first and then calls ~/.bash_profile.
Cancellation:
Bash calls ~/.bash_logout.
Execute the new shell:
In desktop management programs such as KDE,GNONE,ICEWM, execute terminal programs or perform manual/bin/bash, or invoking the she
command-line mode: For I in {1..10};d o echo $i;d one =========================================== while loop statement usage while condition to meet cond Ition executes the cmd do-cmd-done bash-x to run the script in debug mode to display the script's running process until loop statement usage: Until condition--G
t; does not satisfy the condition, then executes the cmd do cmd-done case multi-conditional Judgment Statement usage: Case value in va
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.