Flexible combination of Linux/unix shell and SQL variable transfer, greatly improve the efficiency of the DBA, this article for Linux/unix Shell SQL passed between the variables given a few simple examples for reference.Linux/unix cut with Sql,ramn
Scenario: Fake tune There are several files like this in your directory1.jpg?v=12.jpg?v=23.jpg?v=34.jpg?v=4What if the v=x of the file is removed?Method One: Direct write command implementation using AWK shell command implementationls | awk ' {split
As mentioned above, the shell is a scripting language, so there must be an interpreter to execute the scripts.The common shell scripting interpreters on Unix/linux include bash, sh, csh, Ksh, and so on, which are used to call them a shell. We often
#!/bin/shFor1 () {For I in 1 2 3 4 5 6Doecho "$i"Done}For1#!/bin/shFor2 () {For i in {1..10}Doecho "$i"Done}For2#!/bin/shFor3 () {Sum=0#int =1For i in {1..100..2}DoLet "Sum+=i"Doneecho "Sum is $sum"}For3#!/bin/shFor4 () {Sum=0For I in $ (SEQ 1 2 100)
Filter GawkGawk is a language that can perform pattern scanning and data processing. Gawk searches for one or more files, finds records (usually rows) that match the pattern, and processes the records by performing the specified actions.
Gawk
1. Bash = Bourne Again SHell2. Terminal prompt:#普通用户 [email protected]$ #管理员用户 [email protected]#3. The shell script is usually a text file that starts with Shebang:#! /bin/bashShebang is a line of text where #! is before the interpreter path.
Awk-f ': ' {print $3,$4} ' 1.txtAwk-f ': ' ofs= ': ' {print $3,$4} ' 1.txtawk '/root|user/' 1.txt matches root or userawk '/(OO) +/' 1.txt one or more ooAwk-f ': ' $1~/r*o/{print $} ' 1.txt the first paragraph to match r*o, and only print the third
The recent obsession with Shell, very interested in it, today is mainly about me a beginner in the execution of shell scripts when the problem encountered:As with all languages, the learning of Linux language starts with Hellworld, so now I have
# Vim/mysh/ipscan.SH #!/bin/bash# Scan the local alive ipaddress# .- the- -if[-F $filename]; Then Echo "The file is exist" forNinch{ -..106}; DoHost=192.168.0. $nPing-C2 $host &>/dev/NULL if[ $? =0]; Then Echo "$host is up"
LL is the alias of Ls-l. You can customize aliases to accommodate certain options in place of certain commands, or you can define aliases to combine multiple commands. For example, define an RM alias RMB to automatically back up to the directory
Writing a script today meets a strange thing.Variable A is definedIf [-a $a];then echo "exists"; else echo "not exists"; fiResult output:ExistsIt's a blind moment, but it's going to change.If [-a "$a"]Of course, a here is a script input parameters,
1. Entering a child shell after using parentheses does not have an impact on the current shell.root#/opt/lxb/dir1# (CD/OPT/LXB/DIR2;PWD)Execution only returns a directory of/OPT/LXB/DIR2, but the current shell is still in Dir1.2, Linux under the TAB
[[email protected] scripts]# cat lvs_start.sh#!/bin/sh#----------------------------- ---------------#Author: created by zhangyiling 2016-06#mail: #Function: this scripts function is lvs start|stop#version:4.1.2#------------------------------------
/bin/bash is the default shell for Linuxsetting, reading, and deleting variablesExample: Name=zhangsan echo $name unset nameYou can view the value of the Echo $HOME $PATH of the environment variableVariable setting, there can be no spaces on both
The hill sort was proposed by D.l.shell in 1959, and the relative direct ranking has been greatly improved. Hill sort is also called narrowing the incremental sortBasic idea:First, the entire sequence of records to be sorted into a number of
1. [email protected] seripts]# cat array.sh2. #!/bin/sh3. zhang= (4. wujiangping5. Shuzhaoqiang6. Renhepeng7. peijiaying8. zhangyiling9. ). for (i=0; iOne by one . Do. echo "This was num $i, then name is ${zhang[$i]}".
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service