I looked at the/proc/net/dev under Linux to record the number of packets and bytes sent and received by each network card. So initiation thought, wrote one. Operation Effect:
Copy Code code as follows:
[root@74-82-173-217
1 matching names with Pgrep
Copy Code code as follows:
if test $ (pgrep-f $ | wc-l)-EQ 0
Then
echo "process does not exist"
Else
echo "Existence process"
Fi
The following are supplementary content:Processes in the
4.1 Sort Text
Sort of 4.1.1 RowsWhen command-line options are not provided, the entire record is sorted according to the order defined by the current locale.In the traditional C locale, which is the ASCII order.
4.1.2 Sorted by FieldThe-K option
First, add suffix
1. Problem: The same directory has a large amount of date-named files, some of which have suffixes, some end with the point, such as 20020101.,20020102.,......,20020101.td,20020102.td ...Requirements: Add all the suffix to the end
Reads a file, assigns each row to an array of variables, and prints it out with a for loop
Copy Code code as follows:
#!/bin/sh
I=1
sum= ' sed-n ' $= ' tmp.txt ' #计算文件的总行数
echo "$SUM"
While Read line
Todo
arr[$i]= "$line"
Because the backstage input colleague, uploads the file the time, to file the same name, but different suffix name, because the file path is very deep, about 10 layers, each layer has dozens of files, so manually find a very troublesome, so write a
Copy Code code as follows:
#!bin/sh
# Find the file for the specified suffix at the specified location, including subdirectories
Usage
# FINDF $ $
# The first parameter is a suffix
# Find the file for the specified suffix and print it out
If, for, while almost all the keywords in all programming languages, in Shell programming is no exception, where if is the most frequently used, because shell programming does not exist in the concept of objects (object), so in the comparison of the
The Nova provides NUMA-related advanced features under the NFV scenario, which provides a script to view the NUMA-related information for compute nodes.
#!/bin/bash function Get_nr_processor () {grep ' ^processor '/proc/cpuinfo | wc-l}
First, debug scripts
Debugging is one of the important features that every programming language should implement, and when something unexpected happens, use it to generate the running information of the script, and the debugging information can
A question about how to automatically delete a specified file after it is larger than 1GB.The batch code is as follows:
Copy Code code as follows:
#!/bin/bash
# when the/var/log/syslog is greater than 1GB
# automatically back it up and
Linux access to new Gmail Mail via command line without entering @gmail.com part
#!/bin/bash
num= "\033[1;36m"
end= \033[0m "
read-p" Enter your mail: "Name
read-p" Enter Pass of Mail: " Pass
atom= ' wget-qo-https://$name: $pass
#!/bin/bash #extracting command text_text_text_line options as Parameters Help_info () {echo "NAME" echo "\t$0" Ech O "Synopsis" echo "\t$0 is a shell test about process Options" echo "DESCRIPTION" echo "\toption like-a-B param1- C param2-d "} If [$#
First, receive the fixed length of the parameter
Copy Code code as follows:
[Root@svn shell_example]# Cat params.sh
#!/bin/bash
#传参测试脚本
echo "My name is ' basename $ ' I ' called as $"
echo "My I-parameter is: $"
echo "My
Writing a:
Copy Code code as follows:
#!/bin/bash
While Read line
Todo
echo $line #这里可根据实际用途变化
Done
Writing two:
Copy Code code as follows:
#!/bin/bash
Cat Urfile | While Read line
Todo
Echo $line
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.