Parameters:-N does not execute script, only checks syntax for errors-V Output the script contents to the screen and execute the script-X executes the script and outputs the content to the screen-N-VTen module () { eval '/usr/bin/modulecmd bash $*'}#/bin/bashif [$15 ];then "Yes"or "else" No " Fiyes-X[[Email protected] sbin]# SH-'['5']' 2operator expected+ echo NonoExpand:Use PS4 to make debugging output line numbers[[email protected] sbin]# echo $PS 4+[[email protected] sbin]# export P
]:~/learn$ cat Args.txt | Xargs SH cecho.sh;Arg1 arg2 arg3#Requirement 3, how do I embed parameters in a fixed command line? As shown below:Copy CodeThe code is as follows:[Email protected]:~/learn$ sh cecho.sh-p args1-1-P args1-1#[Email protected]:~/learn$ sh cecho.sh-p args2-1-P args2-1#[Email protected]sli-pc:~/learn$ sh cecho.sh-p args3-1-P args3-1#Solutions for using Xargs:Copy CodeThe code is as follows:[Email protected]:~/learn$ cat Args.txt | xargs-i {} sh cecho.sh-p {}-1-P arg1-1#-P arg
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
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 _bir-$date _now)) declare-idate_d=$ (($date _l
for the second partition;(3) for Rootfs to provide bash, LS, cat programs and the library files that depend on;(4) Provide the configuration file for grub;(5) The new hard disk is set as the first boot item and can start the target host normally;8. Write a script(1) can accept four parameters: Start, stop, restart, statusStart: Output "starting script name finished."...(2) Any other parameters, all error exits;9, write a script to determine whether a given user is logged into the current system
1. List the directory under the current directory (only one level is required)1 #!/bin/bash 2 for f in ' LS ' 3 do 4 if [-D $f] 5 then 6 echo $f 7 fi 8 done2, the current directory of files (only need a level) listed1 #!/bin/bash 2 for f in ' LS ' 3 do 4 if [-F $f] 5 then 6 echo $f 7 fi 8 done[[Email protected] ~]# date +%f "%T" 2016-02-17 15:54:13Knowledge points : In a shell script, if also often judge about the file attributes, such as whether it i
???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
=" 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.
Share a recently written shell script that enables you to back up the production line files and rollback operations by the file directory structure of the published package.1#!/bin/SH2Path="/home/www/site1"3pub= $path"/release/pub/mboxii/trunk"#发布目录4bak= $path"/release/bak"#生产目录备份文件5Prod=$path #生产目录6pub_file_plus= $path"/release/pub_plus.txt"#增量文件: Publish a new file list log for a package relative to the production package7 8 #执行备份9 Dobak () {Ten #删除
Tags: Configuration ideas nbsp Script Practice post awk bash judgment comparison#!/bin/Bash while : DoRead-P">>>"user [["$user"="Q"]] || [["$user"="Q"]] Break [[-Z $user]] ContinueID$user >/dev/NULL [[ $? -eq0]] Cat/etc/passwd|awk-F:'{print $, $NF}'|grep$user | |Echo "User not exist" DoneThe script implements the target to determine whether the user existsMain ideasThe while do statement implements the loopAdd variable $user exit mechanism use "| |", "", respectively, with operations and or o
the same as [].(4) between multiple [] and multiple [[]], or any of the mixed intermediate logical operators are or | |.1.5 General Examples:(1) Compare the size of the two integers by defining variables, script arguments, and read-in in a conditional expression (prohibit using if) and alerting the user to the results in the form of a screen output. A total of 3 scripts developed, when using script to pass the parameter and read in the way you need to be a variable is a number, and not to give
Linux shell BASICS (6) and Linux shell Basics6. Detailed description of Shell script programming links the content of the above five parts to increase understanding of Shell 01. shell script s
Shell BASICS (9) functions, shell Basics
Functions allow us to divide a complex function into several modules, so that the program structure is clearer and the code reuse rate is higher. Like other programming languages, Shell also supports functions.
much like a C-language functional pointer? Like the C language, Lua's functions can accept a variable number of parameters, which are also defined by "...", such as:function sum (A, B,...)If you want to get ... Represents the parameter that can be obtained by accessing the ARG local variable (table type) in the function.such as SUM (1,2,3,4)Then, in the function, a = 1, b = 2, arg = {3, 4}More valuable is that it can return multiple results at the same time, such as:function S ()Return 1,2,3,4E
Linux shell BASICS (7) and Linux shell BasicsVII. Process Control Condition judgment control in the bash script-[] ([] expression is true) (execute the following command when the result of the front side is true) | (if-case loop control-while-utile-for-break-continue # [abc] # echo $? 0 (true) # [] # echo $? 1 (false) # ["$ USER" = "byf"] ('$? * 'Indicates remov
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.