;NBSP;STATU=0NBsp;| |statu=1if[ "$statu" == "0" ];then echo $filename exists and is a directory. "rm -rf "$path/$filename" echo "deleted this directory! "else echo "$filename exists and is a file, deleting and creating a directory with the same name " rm-f "$path/$filename" mkdir "$path/$filename" echo "Creating now Please ..." echo "$filename Catalogue has been established! "fi ;; esacFor simple instructions, write the logic of the script. Use the TEST-E command to determine if the "log
original content). The final result is consistent with the results we see.
2. Transformation of Ranks
Let me explain the above statement, h means that the content of the pattern space is appended to the hold space, ${...} means the last execution, which means that the contents of {} are executed last, so the contents of the space are consistent with the contents of cat in the last time,x Represents the content of the swap hold space and pattern space , then the contents of the patte
In Linux systems, the two most important files for user account management are/etc/password and/etc/shadow.In the/etc/password file, each line represents an account, but there are many accounts that are system accounts. Like what:Bin, ADM, etc., as well as administrator account root. The rest is for general user accounts.Each line is composed of (to: Split):1 account name;2 password (combined with/etc/shadow);3 UID User ID, where 0 is the root, 1~499 is the system user account, and the general u
Tags: $* operation definition test ifconfig dir rhel Zha preShell languageScript: Can run, a file, can implement some function (command stacking)[Email protected] ~]# vim/root/stu.shecho Hello WorldCat/etc/redhat-releaseUname-rHostnameIfconfig | Head-2[Email protected] ~]# chmod +x/root/stu.sh[Email protected] ~]#/root/stu.shCase 1: Writing a script to create a user[Email protected] ~]# vim/root/user.shUseradd nsd02Echo 123 | passwd--stdin nsd02[Email protected] ~]# chmod +x/root/user.sh[Email p
In order to make the shell script have a certain "judgment" ability, according to different conditions to accomplish different management tasks. Make the script a certain "smart".First, condition test operationFile Test Common operations:-D:: Test for Directory-E: Test whether the directory or file exists-F: Test for file-R: Tests whether the current user has permission to read-W: Tests whether the current user has permission to write-X: Test to set p
What is a shell script sampleLet's look at an example:#!/bin/shcd ~mkdir Shell_tutcd shell_tutfor (i=0; iExample explanation
Line 1th: Specify the script interpreter, here is the interpreter with/bin/sh
Line 2nd: Switch to the current user's home directory
Line 3rd: Create a directory Shell_tut
Line 4th: Switch to the Shell_tut directory
Line 5th: Cycle conditions, 10 cycles
Line 6th: Create a test_1 ... 10.txt file
Li
Tags: ges vim editor nginx root user Form bash script expec Ash rsyncObjectiveLearn about the knowledge reserves required for Shell script programming:Vi/vim Editor Command VIMRC set to be proficientBasic commands, more than 100 skilledBasic and common Network Service commands to be: NFS, rsync, INotify, Lanmp, Sersync, SSH keyI. Shell scripting concepts and exam
BKJIA Translation: It feels great when you understand Shell scripts and can write them smoothly whenever needed. In this chapter, we will teach you how to use scripting to perform complex mathematical operations.
Let's start with the Fibonacci series.
The Fibonacci series, also known as the Golden split series, refers to a series of 0, 1, 1, 2, 3, 5, 8, 13, 21 ......, Each of its items is the sum of the fir
1) View PHP running users:System (' id-a ');?>General PHP running user is Apache2) do a key trust for Apache users:2.1)First look at the Apache user information:# Su-apacheThis account was currently not available.# Cat/etc/passwd|grep ApacheApache:x:48:48:apache:/var/www:/sbin/nologinSwitchApache:x:48:48:apache:/var/www:/bin/bash2.2)Root User action:Mkdir/var/www/.sshChown Apache. /var/www/.ssh2.3)Then switch to Apache User:Su-apacheSSH-KEYGEN-T RSA2.4)Root user, and finally change back to Nolog
Recently do the computer room bandwidth detection. Recently wrote a shell script to ping the IP of the machine room in bulk, returning the failure rate and the average response time#!/bin/bashlog=$1.logecho-n "" > $logfor i in ' Cat $ do/bin/ping-s 1000-f-C $i > Ip.txtecho "' Curl ip.cn? ip= $i ' Cat Ip.txt |grep transmitted |Gawk ' {print $6} ' cat Ip.txt |grep avg | Gawk-f/' {print $} ' >> $logdonerm-rf ip.txtStore all IP required for detection in t
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
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.