spaces. If IFS is null, the parameters is joined without intervening separators.oldifs= "$IFS" ifs= "" array= ($result) ifs= "$oldIFS" for I in ${array[@]}; Doecho $idone# Use Facter to get a set of Key-value# Facter output has a newline character, you must replace the newline character with a space# Replace newline characters with spaces to use awk or sed# awk-v rs= "" ' {gsub ("\ n", "");p rint} '# ECHO-E "2 \n1" | Sed ': A; n;$!ba;s/\n//g 'result=$ (facter | awk '/ipaddress/!/ipaddress_lo/{p
#shc是一个专业的加密shell脚本的工具. Its role is to convert the shell script into an executable binary file, which is a good solution to the script contains IP, password and so do not want to open the problem.HTTP://WWW.DATSI.FI.UPM.ES/~FROSAL/SOURCES/SHC's official websitewget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgzTAR-XF shc-3.8.9.tgzCD shc-3.8.9Mkdir-pv/usr/local/man/man1#这步是必须的, because SHC will ins
Common shell scripting use cases, from the online reference and after the modification of the work, in addition to the wiki in the company to write records, it is necessary for a blog to record a drop.Combat Problem 1:Use the For loop to create a batch of 10 files in the/oldboy directory, with the name in turn:Oldboy-1Oldboy-2......Oldboy-10Answer:[[Email protected]]# cat 1.sh#!/bin/bashFor iin ' seq 1 10 '
[Consolidate shell Basics] shell Basics
Address of this Article
Sharing outline:
1. Functions in shell
2. array in shell
3. Variables in shell
4. Operators in
file not found and then exit and return the corresponding value4. Created user login shell for/bin/false5. This script does not need to set a password for the user6. You can get the user name list as a test Http://rhgls from the URL below. Domain11.example.com/materials/userlistVim mkusers.sh#! /bin/bashIf [$#-eq 0];thenEcho ' Usage:/root/mkusers 'Exit 1Fiif [!-F $]; ThenEcho ' Input file not found 'Exit 2FiWhile Read lineDoUseradd-s/bin/false $lineD
, This command keeps the command that is about to jump to another shell terminal to continue running in this terminal.The end of the logo is EOFThe two empty lines in the middle represent the carriage return, the default meaning.1 umount/dev/mmcblk1p1 2 /dev/ mmcblk1p13 umount/ dev/mmcblk1p2
There are some files and directories under the current directory, each of which has several. txt files in each directory.It is now required to create a new directory in the current directory all, and all of those directories will have a. txt fileare copied to the directory all. The shell script in ubuntu12.04 is implemented as follows:#!/bin/sh# Hint Informationecho "Start:"# define VariablesDst=allPst=.txt# Copy files to destination folderIf [-D ${DS
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 '
-i ' $myline ' s/$/\a\nupstream fdfs_group1 {\ n server ' $tempvar ': 8080;/'/root/my/mybin/sbin/test.configSed ' 3a 123 ' 1.txtSed-i ' $myline ' a\nupstream fdfs_group1 {\ n server ' $tempvar ': 8080; '/root/my/mybin/sbin/test.configFive, the operation of the variableThe operation should be placed in square bracketsKnown variable myline, the variable plus 2 should be written as: $[myline+2]Vi. Replace the value of a string that appears several timesUnlimited:Sed-e ': a;/\ (. *abc\) \{3\}/{s/abc
Simple needs to explain shell+expectInstall the Expect,yum installation firstYum Install Expect-y#!/bin/baship= ' 192.168.80.20 ' #定义远程交换服务器的IPpassword= ' [email protected] ' #定义输入的密码Expect Spawn ssh [email protected] $ip ls #在expect中执行命令Set Timeout-1 #定义超时时间, 1 is never timed outExpect "*:" #如果输出 *:Set Timeout-1Send "$password \ r" #自动输入passwordExpect EOF #结束EofThis article is from the "Eight Miles" blog, so be sure to keep this source http://5921271
;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
{Command1Command2Command3}CommentsAs with the shell, the comment uses the #Replace[Address] S/pattern/replacement/flagsThis means that the part of the address line that matches the pattern is replaced with replacement.Of these, flags have several values:A number from N 1 to 512 that represents the substitution of the nth occurrence of the specified pattern in this mode.G makes a global change to all occurrences of the pattern space, and by default onl
To see what versions of the Shell:cat/etc/shells system are currently running, the first process that starts is initHow bash Shell debugs:Simply add parameters after the SH command-N: Do not execute scripts, query the grammar within the scripts, if there are errors are listed!-V: The contents of scripts are displayed on the screen before executing the scripts;-x: The scripts content that will be used is displayed on the screen, slightly different from
' test.in//Print line 3rd to 5th Sed–n '/hello/p ' test.in//print out lines containing hello Sed–n '/hello/= ' test.in//print out line numbers with Hello Sed–n '/hello/d ' test.in//delete the line containing Hello Sed Common editing commands The SED replace command uses the format "Address" s/old word/new word/"GPW" Address: If omitted, indicates that all rows are edited G: Global substitution, default means replacing only the first word to match P: Print the modified line W fname: Writes the
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.