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.

Nginx Support Web Interface Execution Bash script

has always been in the terminal execution shell and other scripts, whether the Web interface can also do so, of course, is also possibleThis article takes CentOS 6 as an example to install the configuration Installing spawn-fcgiwget Https://github.com/lighttpd/spawn-fcgi/archive/spawn-fcgi-1.6.4.zipUnzip Spawn-fcgi-1.6.4.zip RM spawn-fcgi-1.6.4.zipMV spawn-fcgi-spawn-fcgi-1.6.4/spawn-fcgiCD spawn-fcgi/./autogen.sh./configureMake make install Installing FcgiwrapYum-y Install fcgi fcgi-dev

Script format of the--/bin/bash^m: there is no file or directory

The bash script under Linux does not support line breaks \r , and if you run a file that is copied from Windows, you /bin/bash^M: 坏的解释器: 没有那个文件或目录 may want to check if the file format is incorrect.If this is a format problem, there are two ways:First, find the replacement method First step: cat -A filename view ' \ 及 r \ 空白符, n \ 会显示为 r \ ,而 会显示为 ^m '. S

[Go] Bash script: How to read a file in a row (best and worst way)

There are many ways to read a file with a bash script. Look at the first part, I used the while loop and its subsequent pipe command (|) (Cat $FILE | while reading line; do ...) and increment the value of I in the loop, and finally, I got what I wanted. The main reason is that the pipeline command initiates a child shell to read the file, and any operation in the (Child Shell's) while loop (for example, I +

Shell Script error:-bash: xxx:/bin/sh ^ M: badinterpreter: Nosuchfi

Today, I wrote a shell script and reported an error during execution. the script content is simple and only for testing: Shell Code :#! /Bin/shecho quot; testshell quot; the specific error message is as follows: Shell code: [root @ localhosttest] #. /test. sh-bash :. /test. sh:/bin/sh ^ M: bad... today, I wrote a shell scri

The---------Linux Bash script programming---Select Execute

result of the execution state result is not 0.Single-Branch condition judgmentIf condition, then the execution status result of the condition is 0 end or if condition then the execution status result of the condition is 0 end2 Branch condition judgementIf condition, then the execution status result of the condition is 0 otherwise the execution state result of the condition is not 0 end or if condition then the execution state result of the condition is 0 otherwise the execution state result of

Linux01-bash script programming System cropping 51

Up (BASH script Programming copy system library file )To re-edit grub as silent mode:1.vim/mnt/boot/grub/grub.confDefault=0Timeout=3Title Nick Linux (2.6.18)Kernel/vmlinuz ro root/dev/hda2 QuietInitrd/initrd.gzHow to implement terminal prompt information:2. Copy the host file:cp/etc/issue/mnt/sysroot/etc/3. Re-edit issue information:Vim/mnt/sysroot/etc/issueNick release 5.9 (Final)Kernel \ r on an \mHttp://

Bash Script programming case statements and scripting options advanced

the following several casesValue 1) This is not the condition, but the value of the variable, the first value of the variableExpression...;;( None of the options can end with a double semicolon)Value 2)-the second typeExpression...;;...*)Expression...EsacValue can have more than oneExercise: Write a script that asksLet the user type the content from the keyboard and then use our

Linux bash-Script Basics

Script execution:The script starts a child shell process when it executes. Scripts that are started on the command line inherit the current shell environment variables, and the system-initiated scripts (not command-line launches) require a self-defined amount environment variable.Program Status Return code:0: Execute correctly.1-255: Error execution, 1, 2, 127 system reserved.Exit Role Exits

Bash shell-Generic Project Upgrade script

#!/bin/bash################################################################################# Filename:upgrade_ Project.SH# Summary: Project Upgrade Script # LICENSE:GPL # Version:1.0# Author:jet bi# Email:1207501666@qq. com# Date: ./ ,/ ,# Note: #1requires project support for SVN upgrade mode and is equipped with svn#2need restart_tomcat.sh to exist #3. Use description # Upgrade:./upgrade_project.SH-P Proje

Bash script for exporting MySQL database mode and Data

ArticleDirectory Bash script file: export_db.sh Bash script file: export_db.sh #! /Bin/sh # Export_db.sh# Exporting database modes and Data# Codingstandards@gmail.com# V1: 2010-05-23# V2: 2011-10-08/09 # Command instructions# Read Database Name and table name from standard input# Usage: export_db.sh#

A minimalist Daemon bash script

Because of the recently written node. JS program Because of some bugs, there will be some automatic exit problems, so it needs to be found in time when it exits, and restartSo looked up some information, wrote a bash program, the function is very simple, is every 3s to determine whether the node program at 6000 port is running, if not found 6000 port, then the command to execute the startup program, has been used for a period of time, feel good, simpl

String operations in bash Script Programming

. $ {Varname % pattern} If the pattern matches the end of the variable value, delete the shortest matching part and return the remaining part. $ {Varname % pattern} If the pattern matches the end of the variable value, delete the longest matching part and return the remaining part. $ {Varname/pattern/string} Replace the first part that matches pattern with string $ {Varname // pattern/string} Replace all matching parts of pattern with string

Linux Shell script error:/bin/bash^m:bad interpreter:no such file or directory

Today, there is a very strange problem, the shell script that has been running very normal failed, but yesterday added a parameter.Error message:/bin/bash^m:bad interpreter:no such file or directoryLater found that root cause, modified the file yesterday in Windows modified save, and then uploaded. The file is recognized as a DOS format.Use the following command in this command mode to view:: Set FFreturn R

Iii. settings for Bash script parameters

Settings for Bash script parametersSelect parameter Add|del Add Delete user1-user10#! /bin/bashIf [$#-lt 1];thenecho "Usage:adminusers ARG"Exit 5Fiif [= = '--add '];thenFor I in {1..10};d oIf ID user$i >/dev/null;thenecho "user$i exists."ElseUseradd-r user$iecho user$i |passwd--stdin user$i >/dev/nullecho "ADD Uesr$i finished."FiDoneelif [= = '--del '];thenFor I in {1..10};d oif! ID user$i >/dev/null;thenec

Linux Next button installs PowerShell, the bash script

DescriptionCurrently, PowerShell under Linux is approximately equal to pash. I hope you focus on mono, focus on pash.One-click installation script includes for Centos6,centos7,ubuntu 14.04 Ubuntu 14.10Installation script is installed with Yum or APT, mono official latest version, then compile and install the latest version of Pash, and finally generate two commands:Mybuild for compiling pashMypash for runni

Bash force script execution by a user

Inspired by the oneStack script: It turns out that the script can be executed with a certain user permission easily. The script content is as follows: #! /Bin/bash # filename: test. sh # email: wangxiaoyu@Live.com # date: 2013-09-02user = "root" if ['whoam '! = "$ {User}"]; then exec su-"$ {user}"-c "sh $ {PWD}/test

Bash Script Programming 21 MongoDB automatic deployment

This is the automatic deployment of the standalone version. For manual deployment, refer to my other article: Http://blog.csdn.net/sheismylife/article/details/6737127 First download the mongodb-linux-x86_64-2.2.0.tgz, decompress it and put it under the project directory MongoDB. Then prepare the startup script MongoDB: #!/bin/sh ### BEGIN INIT INFO# Provides: mongodb# Required-Start:# Required-Stop:# Default-Start: 2 3 4 5# Default-Stop:

Bash script that automatically partitions and formats a hard disk

#!/bin/bash#fdisk-l | grep "^disk/dev/[sh]d[a-z" | awk ' {print $} ' | Sed "[emailprotected]:@@g" Read-p "Your choice Partdisk above:" partdiskif [$PARTDISK = = Quit];then echo "quit. ." Exit 0fiuntil Fdisk-l | Grep-o "^disk/dev/[sh]d[a-z]" | grep "^disk ${partdisk}$" >/dev/null;d o read-p "wrong choice Your Choice again:" Partdiskdone read-p "would des Troy all data continue[y/n]: "choiceuntil [$CHOICE = =" Y "-o $CHOICE = =" n "];d o read-p" would

Multiple bash Log in history write issue

Question: If a user is opening several bash interfaces at the same time, which Bash's history command record will be written in ~/.bash_history?A: All bash has its own histsize pen recorded in memory, because the log file will not be updated until the logoff, so the last bash will be last written, and the other bash co

Bash commands-create a script with multi-parameter

#! /Bin/bash# Call this script with at least 10 parameters, for example#./Scriptname 1 2 3 4 5 6 7 8 9 10 Minparams = 10 Echo Echo "the name of this script is \" $0 \"."Echo "the name of this script is \" 'basename $0 '\"." Echo If [-n "$1"]#-N test string be quoted is not null.ThenEcho "parameter #1 is $1" # Need quot

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