Linux shell simple implementation of automatic database backup

Take the CentOS system as an example to realize automatic database backup.1. Write a shell: 12 #! /bin/bashMysqldump -cp --user=root --password=' 123 ' dbName | gzip > ~/db/dbname -'date +%y%m%d%H '. SQL. GZ ;

Shell execution prints the variables in the script to the specified log file

In order to locate the problem, we need to locate the running log or error message of the task.When some scripts are called through the shell, the log information is printed in the shell. However, there are users in the shell call normal, but to

Enterprise Shell face question 1: Batch generate random character file name case

use the For loop to bulk create 10 HTML files in the/oldboy directory, where each file needs to contain 10 random lowercase characters plus a fixed string oldboy, with the following name examples:[[email protected]]# ls/oldboyapquvdpqbk_oldboy.html

Shell output 100 + summary of methods

Python-c "Print (' + ' *100)"Head-c 100/dev/zero |awk ' gsub (/./, "+") 'Perl-le "Print (q (+) x100)"println ("+" *100)method to output 50 x = echo "" | Sed ': A; s/^/=/; /=\{50\}/b; Ta Sed ': A;s/^.\{0,49\}$/&=/;ta ' awk '

Write bulk-packaged log scripts with the shell

Script 1#!/bin/bashdate=$ (date +%y%m%d%h%m) name=$ (echo $1 | awk -f ', '   ' {Print NF} ') Log_path= "$" if [ $# -ne 2 ];then    echo  "USAGE: sh  $0 log_name1,log_name2 log_path "    exitfifor NUM in " seq  1  $NAME ' do    log_name=$

HDU5730 Shell Necklace

This article ljh2000Author Blog: http://www.cnblogs.com/ljh2000-jump/Reprint please specify the source, infringement must investigate, retain the final interpretation right!Title Link: HDU5730Positive solution: divide and Cure $fft$Problem Solving

The method of generating random numbers in Shell series

One: RANDOMEcho $RANDOMRandom number is a range of 1--32767, generally used it can be cracked1.2 Generate a eight-digit random password:echo $ (($RANDOM +11111111))Two: Md5sum random encryption method generates a longer passwordTake 9-digit password:

Shell combined with expect for automatic password entry

Shell combined with expect auto-input Password example1#!/bin/Bash2 3cd/data/Live4 5/usr/bin/expect EOF6Spawn git clone"ssh://xxxxxxxxxxxx"7Expect"*passphrase*"8Send"passwordhere\n"9 expect EOFTen EOF One A Time= '/bin/Date "+%y%m%d%h%m%s"` -CD

Useful shell Commands

Netstat netstat-print network connections, routing tables, interface statistics, masquerade connections, and Mul Ticast Memberships See Parameters: -A (All) displays all options and does not show listen related by default-

Shell Bulk Add Users

#!/bin/bashRead-t 30-p "Please input user name:" NameRead-t 30-p "Please input user number:" numRead-s-T 30-p "Please input user password:" PassEcho-e "\ n"if [!-Z "$name"-A!-Z "$num"-A!-Z "$pass"]ThenY=$ (echo "$num" | sed-e ' s#^[0-9]# #g; s#[0-9]*

Linux Shell common Commands

For loopapplist= (App1 app2 app3); for apps in ${applist[@]};d o echo $app;d one; Get IP AddressIfconfig |grep-po ' (? Ifconfig|awk-f "[:]+" ' $4~/[0-9].+[^0-9]+/{print $4}/lo/{exit} 'Ifconfig|sed-nr ' s/^[[:space:]]+inet addr: (. *) bcast.*/\1/p '

Shell script Programming Pass parameters

Positional parameter variablesmyscript.sh ARGU1 ARGU2Citation method:$, $, ..., ${10}, ${11}, ...When executing scripts on Linux, place the parameters behind the script (myscript.sh argu1 argu2), $n represent the parameters to be executedExercise:

Linux Shell Types

One: The type of shell that stands in terms of user login:Login Shell: Normal usually a terminal login Su-usernamesu-l USERNAMEOpen Command Window under non-login SHELL:SU username graphics terminalTwo: Bash configuration file:Global

Shell implements a springboard machine

Zbuz add users, and bulk distribute SSH public key scripts: #!/bin/bash. /etc/init.d/functionsfunction add_user () {         jumper= "$"         useradd ${jumper}         echo 123456 | passwd --stdin ${jumper} >/dev/ null 2>&1              

shell-Regular Expression

One, regular expression. Represents any single character650) this.width=650; "height=" src= "http://b287.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ sdbj9wszq8xdepnsuukfasw8eaay*4jnuepopfpw.oo!/b/db8baaaaaaaa&bo=eaeoaqaaaaafeeu!

Shell-awk Common usage

awk is also a data processing tool and is a basic language that can customize variables, loop array regular functions, etc.awk-f delimiter ' commands command ' file' Condition {Execute} ' condition {execute} ' multiple conditions can use various

Case commands in the shell

The case statement and the judgment statement [If...elif...else] function similarly;When logic is relatively simple, the code is much less than the latter.Case usage, use a variable to match a value, if the match succeeds, execute the command below

Shell instance (i)

Shell instance (i) Example one: equals-eq (equal)Unequal-ne (not equal)Greater than-GT (greater than)Smaller than-lt (less than)Greater than or equal to-ge (greater than or equal)Less than or equal to-le (lesser than or equal)Examples

Shell script Basics--arrays

Q1. ArraysWe know that variables are memory space, each variable can only store a single data, a one-time assignment operation, then encountered some need to continuously store and read the task, if you still rely on the variable for multiple

Java calls the shell script and returns the result set

1 /**2 * Run shell scripts3 * @paramShell scripts that the shell needs to run4 */5 Public Static voidExecshell (String shell) {6 Try {7Runtime RT =runtime.getruntime ();8 rt.exec (shell);9}Catch(Exception e) {Ten

Total Pages: 541 1 .... 456 457 458 459 460 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.