bash shell scripting tutorial

Want to know bash shell scripting tutorial? we have a huge selection of bash shell scripting tutorial information on alibabacloud.com

Shell scripting Exercises (12.7)

Example 1. Enter any two numbers and make a judgmentVI number.sh#!/bin/bash#written by Lizhengecho "Please enter the number"Read aRead Bif test $a-eq $bThen echo "The No.2"Elif Test $a-gt $bThen echo "The > no.2"else echo "The Fi650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/40/wKioL1hIKCagQPMiAAAYfWCqQ_8745.png-wh_500x0-wm_3 -wmp_4-s_1863110480.png "title=" 555.png "alt=" Wkiol1hikcagqpmiaaayfwcqq_8745.png-wh_50 "/>

Shell Scripting Learning

Distance from the last write and a period of time, the period has been followed by private food learning, or did not develop a regular record of the habit, today to write the first script.After a few days of accumulation, learning the next shell script writing, the current master is not too mature, everything is certainly right from the beginning, write a simple bar (difficult will not write O (╯-╰) o).The way this script is executed is to enter the b

Shell scripting learn to summarize the differences between--break and continue

Break is to jump out of the current loop, and continue is to jump out of the loop and start the new loop again[Email protected] test]#CatDemo.SH #/bin/Bash while true; DoRead-P"Please input number:"x yif((x>9)); ThenContinueelif((y>9)); Then BreakElseZ=$ ((x+y))Echo$zfi DoneEcho "Execution completed!"[email protected] test]#SHDemo.SHPlease input number:1 23Please input number:Ten 2 # $x >9, when the back part of the secondary loop is not executing,

Shell Scripting Learning Summary--variables and environment variables

行脚本参数的个数Echo '$*='$* #所有参数变成一个字符Echo '[Email protected]='[email protected] #所有参数basename$0 #获取文件名dirname$0 #获取文件的目录[email protected] sbin]#SH/usr/local/sbin/test.SHAA bb$0=/usr/local/sbin/test.SH$1=aa$#=2$*=AA Bb[email protected]=AA bbtest.SH/usr/local/sbinProcess state variables$? Gets the return value that executes the last command (0 is successful, others are failed)$$ getting the PID of the current shell$_ gets the last parameter of the previous c

"Shell Scripting Learning-2"

Tags:tty a regular expression devproject passwd regular penwho #!/bin/bash-#echo do what exetuate this project \nprintf "Please input your passwd" Stty-echoread Pass Shell Scripting Learning-2

Shell scripting Learn (2) compare two digit sizes

Tags: meaning cond centos7 test cat size pre BER syntax errorNote: The comparison string in the shell can only be used = =, Compare numbers using-eq,-ne,-gt,-ge,-lt,-le, or = =, [[Email protected]SH]$CatNumber_compare.SH #!/bin/bash# script Name: Number_compare.SH#用途: Compare two digit sizesEcho "Please input first number :"Read xEcho "You first number x= $x"Read-P"Please input second number:"yEcho "You s

About shell scripting when value too great for base (Error token is "08")

A problem was encountered today when writing a timed CP script, value too great for base (Error token is "08")The number system that originally started with 0 is recognized by default as an octal number, so my $datem-1 gets the month of the month in return: value too great for base (Error token is "08") This error, the solution isThe $datem format or the declaration is called decimal, ' 10# $datem '-1 so it can. That is, the variable or number that will be converted to decimal is preceded by a '

Shell scripting topics-----------fully automated compilation and installation of MySQL

/local/mysql/--datadir=/usr/local/mysql/data/--user=mysql ls/usr/ Local/mysql/data/ln-s/usr/local/mysql/bin/*/bin/service mysqld start echo "Now let ' s begin mysql_secure_installation "If [! -e/usr/bin/expect] then yum install expect-y fi echo ' #!/usr/bin/expect set timeout set password [lindex $argv 0 ] Spawn mysql_secure_installation Expect {"Enter for none" {send "\ r"; exp_continue} "y/n" {send "y\r"; Exp_continue} "Password" {send "$password \ r"; Exp_continue} "cleaning up" {send "\ r"}

[Android] installs busybox--full bash shell for Android (favorites)

Have you ever had this experience, enter the ADB shell at the command line, and then use the command to manipulate your phone or simulator, but those commands are a shrinking version of the common Linux commands, which is very uncomfortable to use. Ever thought about using a more complete shell on Android? Use BusyBox. Whether using the ADB connection device using the command line or directly on the phone w

[Android] install busybox for Android-the complete BASH Shell

Have you ever had this experience? input ADB shell in the command line and then use the command to operate your mobile phone or simulator. However, these commands are common Linux commands, which are not easy to use. Have you ever thought about using a complete shell on Android? Use busybox. You can use terminal emulator either by connecting to the device using the ADB command line or on your mobile phone.

Install busybox for Android-the complete BASH Shell

Have you ever had this experience? input ADB shell in the command line and then use the command to operate your mobile phone or simulator. However, these commands are common Linux commands, which are not easy to use. Have you ever thought about using a complete shell on Android? Use busybox. You can use terminal emulator either by connecting to the device using the ADB command line or on your mobile phone.

One of the Linux Shell Scripting Learning and combat

updated successfully.Changing password for user bruce03.Passwd:all authentication tokens updated successfully.Changing password for user bruce04.Passwd:all authentication tokens updated successfully.Changing password for user bruce05.Passwd:all authentication tokens updated successfully.Changing password for user bruce06.Passwd:all authentication tokens updated successfully.Changing password for user bruce07.Passwd:all authentication tokens updated successfully.Changing password for user bruce0

Shell Scripting Exercises

Write a small script to calculate how many days you have for your birthday.#!/bin/bash# Enter your birthday date, calculate how many days you have birthday #2015 July 20 read-p "Please enter your birthday date (YYYYMMDD):" date1date_d=$ (echo $date 1|grep ' [0-9]\{8\} ') if[ "$date _d" == "];thenecho" You typed the wrong format ... "exit1fideclare-idate_bir=" date --date= "$date 1" +%s ' declare-idate_now= ' date+%s ' declare-idate_left=$ (( $date _

Some easy-to-confuse concepts about shell scripting

???Because in IO redirection, the standard output is prepared before it is read from the standard input to the standard output. is not a bit around.It's like passing the baton in a relay race; you don't see the guy with the stick, you're definitely not going to send the baton out.So, in the cat 3. How variables are evaluated in a for loopA. Taking values from a set of stringsFor Var in one, three four fiveDoEcho ****************************Echo ' $var is ' $varDoneB. Taking a value from a positi

Shell Scripting Exercises

=" Wkiom1dpl2tdsdtraaaoaz2doqg510.png "/>2. Progress barTo write a simulation progress bar using a shell script:#!/bin/bashstr= "" Arr= ('-"\" | "'/')//define array to simulate cursor rotation for ((i=1; iTo run the program:650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/83/0A/wKioL1dpMCOgKMMxAAAJrNtGHEA737.png "style=" float: none; "title=" Shell3.png "alt=" Wkiol1dpmcogkmmxaaajrntghea737.png "/>650) this.width=650; "src=" Http://s4.51cto.

A detailed explanation of variable types in the Linux bash shell

This article mainly introduces the Linux bash shell in the variable types of detailed, variable types are divided into local variables, local variables, environment variables, position variables and special variables, etc., the need for friends can refer to the In the Linux system for day-to-day operations or scripting, variables are more familiar with, but what

Advanced Bash-shell Guide (Version 10) Learn note one

I like a wordThe only-to really learn scripting are to write scriptsThe only way to learn a script is to write a scriptBetter command-line parameter detectione_wrongargs=85 # non-numerical argument (Bad argument format).41 ## case "$" in# "") lines=50;;# *[!0-9]*) echo "Usage: ' basename $ ' lines-to-cleanup";No number in the middle of the argument, invalid argument# exit $E _wrongargs;;# *) lines=$1;;# ESACMore Efficient directory detection3 # Cd/var

Shell Scripting related issues

command willSHELLmeta-characters are expanded. 4. In the double-brace Test command, if a string (with or without a space) is simply the expression as a normal string, not part of a pattern, it must also be enclosed in quotation marks. If a string value (the one on the right) is not enclosed in double quotes, the string is a pattern, and if it contains SHELL metacharacters, bash expands it. If the string i

Shell Scripting Learning

out the last/and left string: my.file.txt${file#*.} Take out the first one. And the string to the left: file.txt${file##*.} Take off the last one. And the string to the left: txt${file%/*} take out the last/And right string:/dir1/dir2/dir3${file%%/*} take out the first/and the right string: (null value)${file%.*} take off the last one. And the string to the right:/dir1/dir2/dir3/my.file${file%%.*} take off the first one. And the string to the right:/dir1/dir2/dir3/myTest.sh:File=dir1/dir2/dir3/

Shell scripting introduction, structure and execution, variables, and date command usage

Tags: distinguishing string roo Interactive process%s usage definition function efficiencyFirst, Shell script introductionThe shell is a scripting language, and the shell is a collection of system commands1, can use logic judgment, cycle and other grammar;It's a bit like C language, but it's fundamentally different.2,

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