当前位置: 首页 > news >正文

dw里响应式网站怎么做抚顺优化seo

dw里响应式网站怎么做,抚顺优化seo,阿里云机器怎么做网站,网站编辑怎么样awk 命令 awk 是一种处理文本文件的语言,是一个强大的文本分析工具。 awk 通过提供编程语言的功能,如变量、数学运算、字符串处理等,使得对文本文件的分析和操作变得非常灵活和高效。 之所以叫 awk 是因为其取了三位创始人 Alfred Aho&#x…
      1. awk 命令

        awk 是一种处理文本文件的语言,是一个强大的文本分析工具。

        awk 通过提供编程语言的功能,如变量、数学运算、字符串处理等,使得对文本文件的分析和操作变得非常灵活和高效。

        之所以叫 awk 是因为其取了三位创始人 Alfred Aho,Peter Weinberger, 和 Brian Kernighan 的 Family Name 的首字符。

        这里我们有一个文本文件test.txt

        1 2 3 4 5 6
        test1 test2 test3 test4
        There are some words
        there are some numbers
        

打印整行:

# awk '{print}' test.txtroot@hcss-ecs-c2b8:/var/test# awk '{print}' test.txt
1 2 3 4 5 6
test1 test2 test3 test4
There are some words
there are some numbers

打印特定列:

# awk '{print $1, $2}' test.txt 
root@hcss-ecs-c2b8:/var/test# awk '{print $1, $2}' test.txt
1 2
test1 test2
There are
there are
root@hcss-ecs-c2b8:/var/test# awk '{print $3, $4}' test.txt
3 4
test3 test4
some words
some numbers

使用分隔符指定列:

# awk -F',' '{print $1, $2}' test.txt 

打印行数:

# awk '{print NR, $0}' file
root@hcss-ecs-c2b8:/var/test# awk '{print NR,$0}' test.txt 
1 1 2 3 4 5 6
2 test1 test2 test3 test4
3 There are some words
4 there are some numbers

打印行数满足条件的行:

awk '/pattern/ {print NR, $0}' file

计算列的总和:

# awk '{sum += $1} END {print sum}' file
# test.txt
1 2 3 4 5
2
3
4
5
6
test1 test2 test3 test4
There are some words
there are some numbersroot@hcss-ecs-c2b8:/var/test# vim test.txt 
# 只会计算数字类型,不能转化为数字的不影响求和
root@hcss-ecs-c2b8:/var/test# awk '{sum += $1} END {print sum}' test.txt 
21

打印最大值:

awk 'max < $1 {max = $1} END {print max}' file

格式化输出:

awk '{printf "%-10s %-10s\n", $1, $2}' file
  1. sed 命令

    Linux sed 命令是利用脚本来处理文本文件。

    sed 可依照脚本的指令来处理、编辑文本文件。

    Sed 主要用来自动编辑一个或多个文件、简化对文件的反复操作、编写转换程序等。

    语法

    sed [-hnV][-e<script>][-f<script文件>][文本文件]
    

    参数说明

    • -e

先创建一个sed的测试文本文件

root@hcss-ecs-c2b8:/var/test# vim sed_test.txt
root@hcss-ecs-c2b8:/var/test# cat sed_test.txt 
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 
Google
Taobao
Runoob
Tesetfile
Wiki

添加文本

# 现在我们在第3行后添加一行文本"Newline"
root@hcss-ecs-c2b8:/var/test# sed  3a\NewLine  sed_test.txt 
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
NewLine
Linux test 
Google
Taobao
Runoob
Tesetfile
Wiki
# cat查看发现他并不会去修改原文件
root@hcss-ecs-c2b8:/var/test# cat sed_test.txt 
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 
Google
Taobao
Runoob
Tesetfile
Wiki
# 我们去第三行前添加文本
root@hcss-ecs-c2b8:/var/test# sed  3i\NewLine  sed_test.txt 
HELLO LINUX!  
Linux is a free unix-type opterating system.  
NewLine
This is a linux testfile!  
Linux test 
Google
Taobao
Runoob
Tesetfile
Wiki

删除指定行数的文本

root@hcss-ecs-c2b8:/var/test# nl sed_test.txt 1	HELLO LINUX!  2	Linux is a free unix-type opterating system.  3	This is a linux testfile!  4	Linux test 5	Google6	Taobao7	Runoob8	Tesetfile9	Wikiroot@hcss-ecs-c2b8:/var/test# nl sed_test.txt | sed '2d'1	HELLO LINUX!  3	This is a linux testfile!  4	Linux test 5	Google6	Taobao7	Runoob8	Tesetfile9	Wikiroot@hcss-ecs-c2b8:/var/test# nl sed_test.txt | sed '2,6d'1	HELLO LINUX!  7	Runoob8	Tesetfile9	Wikiroot@hcss-ecs-c2b8:/var/test# nl sed_test.txt | sed '6d'1	HELLO LINUX!  2	Linux is a free unix-type opterating system.  3	This is a linux testfile!  4	Linux test 5	Google7	Runoob8	Tesetfile9	Wiki

替换文本

root@hcss-ecs-c2b8:/var/test# cat sed_test.txt 
#原文本
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 
Google
Taobao
Runoob
Tesetfile
Wiki
# 替换后的文本
root@hcss-ecs-c2b8:/var/test# sed -e 's/LINUX/UNIX/g' sed_test.txt 
HELLO UNIX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 
Google
Taobao
Runoob
Tesetfile
Wikiroot@hcss-ecs-c2b8:/var/test# sed -e 's/Taobao/JD/g' sed_test.txt 
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 
Google
JD
Runoob
Tesetfile
Wiki

思考:

  • grep 更适合单纯的查找或匹配文本
  • sed 更适合编辑匹配到的文本
  • awk 更适合格式化文本,对文本进行较复杂格式处理

简单编写一个shell脚本使用这两个命令

# alarm_handler.sh
#!/bin/bash# 监控系统资源使用情况,
threshold=$1  # 设置CPU使用率的阈值为threshold%。
cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
# 第二题中出现。grep、sed 和 awk 结合,从输出中提取并计算CPU空闲百分比。# 使用 bc 计算判断CPU使用率是否超过阈值。
if [[ $(echo "$cpu_usage > $threshold" | bc -l) -eq 1 ]]; thenecho "High CPU usage detected: $cpu_usage%"# 如果CPU使用率超过阈值,使用 mail 命令发送邮件给 admin@example.com。echo "High CPU Usage warning,Current CPU Usage: $cpu_usage%"
elseecho "CPU usage within normal range: $cpu_usage%"
fi
root@hcss-ecs-c2b8:/var/test# vim alarm_handler.sh 
root@hcss-ecs-c2b8:/var/test# chmod +x alarm_handler.sh 
root@hcss-ecs-c2b8:/var/test# ./alarm_handler.sh 20
CPU usage within normal range: 0%
root@hcss-ecs-c2b8:/var/test# ./alarm_handler.sh 30
CPU usage within normal range: 3.2%

没跑任何服务的原因,cpu几乎没有任何占用

http://www.yidumall.com/news/49162.html

相关文章:

  • 成都疫情源头终于找到了seo案例分析100例
  • 网站群建设进度外包seo服务口碑好
  • 网站开发任务需求书网站排名优化系统
  • 网站建设价格单武汉seo首页优化报价
  • 企业网站主要功能百度推广怎么做免费
  • 动态网页设计网站建设买卖链接网
  • 城阳网站建设哪里有seo推广公司
  • 洛阳便宜网站建设报价佛山百度推广公司
  • 想做一个自己设计公司的网站怎么做网站 seo
  • wordpress的网站好用吗seo营销是什么意思
  • 做vip兼职设计师的网站有哪些企业网站seo多少钱
  • 公司企业邮箱怎么填写上海网站seo排名优化
  • 昆明哪里做网站天津站内关键词优化
  • 小公司做网站还是微博百度输入法下载
  • 做网站开发工具哪个好百度推广怎么推
  • 旅游网站建设规划书模板下载广州抖音seo
  • c语言网页编辑器seo排名优化收费
  • python可以做网站前端百度网址大全手机版
  • 如何给自己的网站做seo推广app的营销方案
  • 临沂搜索引擎网站推广国外搜索引擎大全不屏蔽
  • 服装网站建设价格百度关键词点击
  • 外贸建站模版西安做网站公司
  • 建设一个小网站需要多少钱西安百度公司
  • 石龙镇仿做网站西安网站公司推广
  • 网站制作行业越来越难做手机建站
  • 让自己的电脑做网站的服务器网站媒体推广方案
  • 网站设计与建设开发百度seo培训
  • 自己怎么做网站品牌推广案例
  • 二手交易网站设计怎么做惠州短视频seo
  • 网站建设优化服务价位公司网站怎么建立