bash scripting basics

Alibabacloud.com offers a wide variety of articles about bash scripting basics, easily find your bash scripting basics information here online.

bash scripting using "=" assignment, left and right cannot leave spaces

When assigning a value of "=" to a script variable, "=" cannot have spaces left or right, otherwise it will prompt an error.For example, the following examples: #!/bin/bashbegin_time = ' date +%h: %m:%s ". /a.outend_time = ' date +%h:%m:%s ' echo ' " echo " $BEGIN _time " echo " " echo " $END _time When the system time is assigned to Begin_time and Eng_time, in accordance with the previous habit, "=" Left and right to add a space, resulting in an error message:[email pro

Linux commands: Bash scripting-Script

'; DoIf ID $DUSER >/dev/null; ThenUserdel-r $DUSER[$DEBUG-eq 1] echo "Delete $DUSER finished."Else[$DEBUG-eq 1] echo "$DUSER not exists."FiDoneFiecho "$DEBUG add: $ADD del: $DEL"[Email protected] ~]#/adminuser33.sh-v--add tom2,tom3--del tom2ADD user Tom2 finished.ADD user Tom3 finished.Delete Tom2 finished.1 add:1 del:1Exercise: Write a script showlogged.sh , which is in the following format:Showlogged.sh-v-c-h|--helpamong them, - H option can only be used alone to display help information; -

Bash scripting seven Save the command output to a variable (reprint)

Transferred from: http://blog.csdn.net/csfreebird/article/details/7978699' symbol contains commands that can be saved to a variable after the command has been executed #!/bin/Bash v= ' java-version ' echo $v Execution Result: $./install.sh "1.6.0_34" 1.6. 0_34- B04) 20.9', English is Backtick, accent.There is another way to wrap the commands in $ (). #!/bin/Bash

Scripting of Bash functions under Linux (11)

Scripting of Bash functions under Linux (11)1. Function of script programming:Function: Structured programming, cannot run independently, needs to be executed when called, can be invoked multiple timesFormat 1:Function name {Statement...}Format 2:Function name () {Statement...}2. Call function Execution status return value:Format: return value, value between 0-2553. Use the function to complete the script t

Linux Bash scripting-command Chaining & Command lists

# this are to show what you are to execute a series of commands in one strike.$ clear; CD/; Ls-l; echo "You is in $PWD"; echo "Time to go home"; CD ~;# Use semi colon between command.# There is also command lists, which are for a different logic# # Double ampersand means anding, double pipe means ORING; When using if only when the first command exits 0 (successful), the later command would be proceeded; When using | |, if the first command exits none of zero (not successful), the later command

Linux Bash Scripting-command Substitution

'-back close or reverse closeShift +tilder? Command ExpansionCat > Lspath.txt/etc^cLs-l ' Cat lspath.txt ' | grep. conf > Etcconf.fileORLs-l $ (cat lspath.txt)Another example using "Du" command:Du-h ' Cat lspath.txt 'Set | grep EtcdirEtcdir= ' ls-l/etc 'Echo $ETCDIR # to reserve the normal format with use echo "$ETCDIR"Netstat-ant | grep 443# # # Checking HTTPS status, if result is 1, it is running; If result is 0, the HTTPS service is dead###Ssl_status= ' Netstat-ant | grep 443 | Wc-l 'Echo $ss

Bash Shell Scripting Learning (ii)

Write a second shell script today and write the after-class questions in "private cuisine". The problem needs to write a check whether a name exists, does not exist to create a file, there is a need to determine whether the name of the file, the file is deleted after the creation of a directory with the same name, if the directory is to delete this directory.First set up a basic condition: The Operation directory is/tmp/test/(note: If this directory does not exist you need to create manually), y

Linux command line and shell scripting---bash shell commands

contains the information and location of the source file. Referencing a hard-link file is equivalent to referencing a source fileCp-l test1 test4The-l parameter creates a hard-link test4 that points to the file test1.Note: You can only create hard links between files on the same storage media, and you cannot create hard links between files under different mount points.The parameter-s creates a symbolic link, or a soft connectionCp-s Test TEST5When copying a linked file, be aware that if you use

Linux basics-Bash command priority, linux-bash priority

Linux basics-Bash command priority, linux-bash priority 1. Bash Introduction The command interpreter, also known as the Bourne Again Shell, originated from the shell. Shell, commonly known as shell, refers to a command parser in a UNIX system. It is mainly used for user-system interaction. There are many types of shell

Linux Learning note--bash scripting one variable, variable type

Bash scripting one variable, variable typeShell Programming:Compilers, interpretersProgramming languages: Machine language, assembly language, advanced languagesStatic language: Compiled languageStrongly typed (variable) languageconvert into executable format in advanceC,C + +,JAVA,C #Dynamic Language: interpreted language On the fiy Weak typeEdge interpretation Side ExecutionASP,asp, PHP, Shell,Python,Pe

Puff---------Linux bash scripting---user interaction

51200083 linuxpartition1doesnotendoncylinderboundary./dev/sda2 64 128131024000008eLinuxLVM/dev/sda3 1281314118 1048981183Linux/dev/sda4 1411915665 12426277+5Extended/dev/sda5 141191542410490413+ NBSP;NBSP;82NBSP;NBSP;LINUXNBSP;SWAPNBSP;/NBSP;SOLARIS2, error path [[emailprotected]scripts]# ./test.shenteradiskNbsp;specialfile:hownosuchfile. [[emailprotected]scripts]#echo$?1[[emailprotected]scripts]#This article is from the "Reading" blog, make sure to keep this source http://sonlich.blog.51cto.co

Scripting for special usage of Bash programming loop statements under Linux (10)

Scripting for the special use of the while statement under the Linux Bash Program (10)1. Loop control:Break: Interrupts the entire loop statement, which is the statement following the execution of the script after exiting the loopContinue: Interrupt the current cycle, advance to the next round cycleExit: End Script Run2.while dead Loop, that is, when you do not know how many times the loopFormat: while:; Do

Linux Bash programming case statements and scripting (eight)

Linux Bash programming case statements and scripting (eight)1.case statement in the following format:Case variable inValue 1)Statement 1...;; Each branch statement ends with a semicolonValue 2)Statement 2...;;*) Other, equivalent if statement elseStatement 3...;;ESAC the entire case statement ends2 . Write a script that adds and deletes the user arbitrarily, with the following requirements:2.1: If the scrip

8.15_linux bash Shell scripting Getting Started (ii) and use of file lookup and compression

Bash shell scripting Getting Started (ii)Use of the Read commandRole:Use read to assign the input value to one or more shell variables:-p Specifies the prompt to display-T TIMEOUTRead reads the values from the standard input, assigns a variable to each word, and all the remaining words are assigned to the last variableEx.read-p "Enter a filename:" FILE650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M

Scripting for Bash programming until statements and formatted hard disk partitions in Linux (10)

Scripting for Bash programming until statements and formatted hard disk partitions in Linux (10)1. Summary of circular statement structure1.1.while Statement Enter the Loop statement when the condition is metWhile condition; DoStatementDone1.2.until Statement Enter the Loop statement when the condition is not satisfieduntil conditions; DoStatementDone1.3.for variable in list; DoLoop bodyDone1.4.for ((expres

4. Bash basics and configurations, standard I/O, pipelines, and shell programming basics;

Labels: Bash basics and standard I/O pipeline shell programming Basics 1. Bash basics and configurations From the user's perspective, the shell type: Logon Shell Log On Through a terminal normally Su-Username Su-l Username Non-Logon Shell Su Username Virtual terminal open

Introduction to ASP Basics (ASP Scripting Basics) _ Application Tips

Please follow me to learn some of the basics of using scripting languages (mainly VBScript) in ASP. Before you begin to learn the scripting language, you should understand some simple concepts--variables, processes. A variable is a named storage location in the computer's memory that contains data such as numbers or strings, which makes it easy for users to unde

Bash basics and shell programming Basics

Bash Basics About commands and command types Use the hash table for the command Bash to accelerate the next search. To add a frequently used command, use the hash cmdBash executes commands with the same name in the path in the following sequence: built-in commands of the alias keywords function executable files or scriptsWhen executing a command entered by a us

Shell Script Programming Learning Note-shell Scripting Basics Introduction

also used "." When invoking the system function library under/etc/init.d/. Point number and source, let's look at the system function library/etc/init.d/functionsYou can also call the library with source, and the action prints out very flashy results, such asThe action in/etc/init.d/functions is a function defined in theWe can also define the functions ourselves in the functions, and then we can invoke the custom function. Such asYou can also send a reference, such asFour Basic specifications a

Linux Learning Notes (*) Shell Basics Bash Basic Features

1 shell overviewThe shell is a command interpreter that provides the user with an interface system-level program that sends a request to the Linux kernel to run the program. The user can start, suspend, stop, or even write some programs with the shell.The shell is a powerful programming language that is easy to write, easy to debug, and highly flexible. The shell is a scripting language that interprets execution and can invoke Linux system commands di

Total Pages: 6 1 2 3 4 5 6 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.