1. Event Description:
1 ,#! /Bin/bash
Cat ../ip.txt | while read line
Do
Echo $ line
SSH $ line "ls"
Done
The result is recycled once and then exited. The reason is that while uses the redirection mechanism. All the information in the file is read
1. For I in 'ls *. mp3'
Common Mistakes:
for i in `ls *.mp3`; do # Wrong!
Why is it wrong? Because the for... in statement is segmented by space, the file name containing space is split into multiple words. If you encounter 01-Don't eat the
Use of the seek () method for file operations in Python
This article mainly introduces how to use the seek () method for file operations in Python. It is the basic knowledge of getting started with Python. For more information, see
The seek ()
This section describes how to use the readline () method in Python.
This article briefly introduces the use of the readline () method in Python. It is the basic knowledge of getting started with Python. For more information, see
The readline ()
How to Use the truncate () method to operate files in Python
This article mainly introduces how to use the truncate () method to operate files in Python. It is the basic knowledge of getting started with Python. For more information, see
The
First script file
Copy Code code as follows:
#!/bin/bash
echo "This are my I-A-bash code!"
Exit 0
redirect Symbols and mathematical calculations
Copy Code code as follows:
#!/bin/bash
Echo-n "The time and
Conditional Select if statement 选择执行: 注意:if语句可嵌套 单分支 if 判断条件;then 条件为真的分支代码 fi 双分支 if 判断条件; then 条件为真的分支代码 else条件为假的分支代码 fi 多分支 if 判断条件1; then 条件为真的分支代码 elif 判断条件2; then 条件为真的分支代码 elif 判断条件3; then
15.1 Understanding inputs and outputsNow you know two ways to show script output1) display on the display screen2) redirect the output file to a file15.1.1 Standard File descriptorEach object is treated as a file by the Linux system. This includes
DDoS deflate is actually a shell script that uses Netstat and iptables tools to block IP that has too many links, effectively preventing common malicious scanners, but it is not really an effective DDoS defense tool.
Work Process Description:
The
Loops are often used in shell programming, and the commonly used loops are for and while loops. While loops read files by default in rows, and for loops read file-splitting files with spaces, this article combines some examples of current web usage
Shell scripting to manage multiple servers at the same time, without the use of ansible, automatic manual implementationSSH does not log on to the Machine execution command (if you have to implement password-free login)ssh 127.0.0.1 ‘ifconfig‘ssh 127
Linux shell reads files by line #/bin/bash printf "*************************** * ******** \ n "echo" cat file whiel read line "cat test.txt | while read line do & nbsp; echo $ line; done printf "************************************* \ n "echo" while
There are many ways to read a file with a bash script. Look at the first part, I used the while loop and its subsequent pipe command (|) (Cat $FILE | while reading line; do ...) and increment the value of I in the loop, and finally, I got what I
The common code for linux shell to read files cyclically by line is as follows:
#/Bin/bash printf "********************************* * *** \ n "echo" cat file whiel read line "cat test.txt | while read line do echo $ line; done printf "***********
Commonly used code for linuxshell to read objects cyclically by line is as follows: #/bin/bashprintf "********************************** * ** \ n "echo" catfilewhielreadline "cattest.txt | whilereadlinedoecho $ lin
The common code for linux shell
In the for loop described earlier, you must first create an element list to determine the number of cycles. However, consider the following example: If you enter "quit", the program will exit, otherwise, convert the characters entered by the user
Linuxshell reads the file line by lineRead File linesCommand to replace code block redirection whilePipeline Code block redirection
IFS=$'\n'for line in `ls -l`do (( count++ ))doneecho $count
Note:When reading for, the system automatically uses
1. Example: Insert a record every 100 rows, and the first column of this record contains the line number, and the other columns are the same as the first row
#!/bin/sh
var= "00001" # variable
cat A.txt|awk ' nr==1 ' |while read Line # Get the
The Shell function returns the value, generally has 3 kinds of ways: Return,argv,echo
1) Return statementThe return value of the Shell function, as in other languages, can be returned through the return statement.Example:
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.