how to write bash script

Alibabacloud.com offers a wide variety of articles about how to write bash script, easily find your how to write bash script information here online.

SHELL: Write NGINX Service Control script, shell: Write nginx script

SHELL: Write NGINX Service Control script, shell: Write nginx script Nginx installed in the source code package cannot use "service nginx start" or "/etc/init. d/nginx start" for operations and control. Therefore, the following service control script is written. You can use

BASH Shell Script Programming

/*************************************** ******************************* Author: Samson* Date: 08/01/2013 **************************************** ****************************/ BASH Shell script programming learning summary: Variable:(1) environment variables: can be modified;(2) internal variables: provided by the system and cannot be modified;$ #: Get the number of parameters$? : ShellProgramReturn

Bash Script Programming 11 JDK automatic deployment

Now we will demonstrate how to use Bash scripts to automatically deploy JDK. Environment: ubuntu12.04 amd 64 desktop or server, which must be BASH Shell Copy the directory Java to the target machine and run the install. Sh script with the root permission. Take a look at the directory structure: . ── Check. Sh ├ ── install. Sh ├ ── jdk1.6.0 _ 35 ── r

Bash's three script exercises and arithmetic operations

Exercise: Write a scriptDetermine if there is a user's default shell for bash on the current system;If so, the number of such users is displayed, otherwise no such user is shown#!/bin/bashAcount= ' grep ' \If [$acount-gt 0];thenecho "There has $acount such users"Elseecho "No such users"FiExercise: Write a scriptGiven a file, such as/etc/inittabDetermine if there

CentOS6 Shell Script/bin/bash^m:bad Interpreter Error resolution method

Save a script file under Windows, upload to CentOS with SSH, add permission to execute Nginx prompt without that file or directory.The shell script is placed in the/etc/init.d/directory, and then executes the/etc/init.d/nginx, prompting more of this sentence/bin/bash^m:bad interpreter.We found the information on the Internet.If the

Back up the Bash script of the MySQL database

If you host your own blog or any Web-based application running on the stack, you shoshould have a backup system in place for keeping data stored in MySQL databases safe. there are several solutions that can help you with that, but nothing beats a simple Bash script I stumbled upon in a blog post comment. here is the script in all its beauty: [If you manage your o

Bash Shell Script Learning Summary _linux Shell

1. Character truncation:If the character truncation is a generic path, you can use both the basename and dirname tools:BaseName can truncate a filename from a file path For example: Copy Code code as follows: $ basename/home/file.tar File.tar DirName can be truncated to a directory path from a file path For example: Copy Code code as follows: $ dirname/home/file.tar /home Do not use external tools for character truncation

Bash control task concurrency script

Bash controls the number of concurrent jobs. The script uses bash to control the number of concurrent jobs. 01 #! /Bin/bash02 #0304 CMDS [1] quot; echo $ USER amp; #39; 01 BEGIN amp; #39; amp; sleep6 amp; amp; echo $ USER amp; #39; 01END amp; #39; quo bash controls the number of concurrent tasks. The

The bash script is registered as a service and automatically started upon startup. details about the chkconfig command

The bash script is registered as a service and automatically started upon startup. the chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig does not automatically disable or activate a service immediately, but simply changes the symbolic connection. Use the bash

7. Text processing, redirection, pipelines, bash arithmetic operations, script input

"/> One-step execution: Bash-x Script Name Exercise: enter two integers A and B, where a 650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4D/D3/wKioL1Ra46nTXoqpAABtpClfocc303.jpg "Title =" script 2121.png "alt =" wkiol1ra46ntxoqpaabtpclfocc303.jpg "/> Now let's take a look at the process. 650) This. width = 650; "src =" http://s3

How to obtain the path in a bash script

DIR = "$ (cd" $ (dirname "$ {BASH_SOURCE [0]}") " pwd )" This is the recommended method on stackoverflow. Http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself I have read it twice. Later I changed it: # DIR = "$ (cd" $ (dirname "$ {BASH_SOURCE [0]}") " pwd )" S0 = "$ {BASH_SOURCE [0]}" DIRNAME = "$ (dirname" $ S0 ")" DIR = "$ (cd" $ DIRNAME " pwd )

Software watchdog example of bash script

#!/bin/sh# file timestamp to record the heartbeat of spring-rest-Servertimestamp=/usr/apache-tomcat-7.0. the/logs/timestamp.log# Timeout 60stimeout=60000# error Logstderr=/usr/apache-tomcat-7.0. the/logs/tomcat-watchdog.log#1means need to Restartrestart=0# the error infoerrinfo="'# Check whether file existsif[ -e $timestamp]; then# Check whether contains valueif[ -s $timestamp]; Thenstart_time=$ (cat $timestamp) # integer Checkif[1-eq ' echo $start _time|grep-p"^-?\d+$"|WC-l ']; Thenend_time=$ (

The Bash script template I used

, warnings, and error messages during a script run are identified with different string prefixes, making them easier to identify. Based on the above considerations, the script template is created as follows:#!/bin/Bashscript_name=""script_usage=$ (Cat Eofdescription of script usage. EOF) script_function=$ (Cat Eofdescription of scriptfunction. EOF) script_do

Use bash to read and write csv file data to one of MySQL database scripts _ MySQL

Scenario: a csv file containing student details of multiple departments needs to be inserted into a data table to ensure that each department generates a separate ranking list. The data in the studentdatacsv file of the learning information table is as follows: 1, NavinM Zookeeper Scenario:There is a csv file containing student details of multiple departments. you need to insert the file content into a data table to ensure that each department generates a separate ranking list. The data in t

Bash Remote Code Execution Vulnerability batch exploitation script

. proxies, verify = false) def geturls (Self): ret_l Ist = [] tmp_list = [] for X in xrange (0, self. pagecount): url = "{apiurl }? V = 1.0 Q = {keywords} rsz = 8 START = {pagecount }". format (apiurl = self. apiurl, KEYWORDS = self. keywords, pagecount = x) Try: r = self. getrequest (URL) Results = JSON. loads (R. text) if not results: continueinfos = Results ['responsedata'] ['result'] If Infos: for I in Infos: tmp_list.append (I ['url']) Does T exception, e: continueret_list = ret_list + t

Java calls Bash shell script blocking small problem resolution

Java calls Bash shell script blocking small problem resolutionBackgroundUsing Java implementation of the Web side, the web side of the corresponding user interface operation, using Java Call Bash implementation of the shell script to do the actual operation, the operation is completed to return the results of execution

Linux bash start stop script, second bomb

This article is an improvement of the shell script of the previous Watchdate Wdate, again first:650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/76/95/wKioL1ZWwy_juP9NAARfY7_6zMo324.jpg "title=" Wdate " alt= "Wkiol1zwwy_jup9naarfy7_6zmo324.jpg"/>1) script Join Chkconfig Management head-5/etc/init.d/wdate#!/bin/bash#auth:[email protected]# #wdate start/s

Bash Script Learning notes Quick Start article

Script Security All of my bash scripts start with the following lines: The code is as follows Copy Code #!/bin/bashSet-o NounsetSet-o Errexit Doing so avoids two common problems: Reference to an undefined variable (the default value is "") Commands that failed to execute are ignored It should be noted that some of the parameters of some Linux commands can be enforc

Linux Learning Note--bash script programming the second, condition judgment

Bash Script Programming second, conditional judgmentCondition Judgment:If the user does not existAdd user, give password and display add success;OtherwiseShow that the user is already present, not addedHow do I make conditional judgments in bash?Integer testCharacter Test File testExpressions for Conditional tests:[Expression][[Expression]]Test expressionInteger

Linux Basic Notes--[008]--08 month 16th class Exercise {Bash script}

Chess#!/usr/bin/bashN=1Test () { forXinch{1..8} doif[[$ ($x% 2) = = ="0"] then echo-E"\033[41m \033[00m" ElseEcho-E"\033[46m \033[00m"fi Done} while[[$n ]]doif[[$ ($n% 2) = = ="0"] Then test>$n. txtElseTest| TAC >$n. txt Filet n+=1Donepaste {1..8}.txt >Result.txtcat Result.txt| Sed's/\t//g'RM Result.txt {1..8}.txttac:international ChessThree, take 10 random number of the maximum and minimum value#!/usr/bin/env Bashmax=$RANDOMmin=$maxecho $max for((i=9;i>0;i--)) do Max_old=$max Max=$RANDOM Ec

Total Pages: 15 1 .... 6 7 8 9 10 .... 15 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.