1.从一串字符串中获取特定的信息 要求1:获取本机IP:menu.lst为系统镜象的IP配置文件,需要从中获取到本机IP信息(从文件获取信息) timeout title live find --set-root /casper/vmlinuz kernel /casper/vmlinuz boot=casper ignore_uuid showmounts ip=eth0,10.0.66.66,255.255.240.0,10.0.64.3 initrd /casper/initrd.lz m…
1.日志文件列表 比如:/data1/logs/2019/08/15/ 10.1.1.1.log.gz 10.1.1.2.log.gz 2.统计日志中的某关键字shell脚本 zcat *.gz|grep 关键字 |grep -oP "deviceid=[^=]+"|uniq|sort -u > /tmp/20190815.log date 格式化出年月等信息,拼接成路径 wc -l /tmp/20190815.log , 获取到行数 php /xxxxx/sendmail.ph…
shell脚本实现读取一个文件中的某一列,并进行循环处理 1) for循环 #!bin/bash if [ ! -f "userlist.txt" ]; then echo "userlist.txt 不存在!" fi for userid in `(cat userlist.txt)` do a=$userid echo $a done #!bin/bash if [ ! -f userlist.txt ]; then echo "userlist.tx…
摘自:<Linux shell 脚本攻略>…
本文为博主原创,转载请注明出处: 最近在进行压测,为了观察并定位服务性能的瓶颈,所以在代码中很多地方加了执行耗时的日志,但这种方式只能观察,却在压测的时候,不太能准确的把握代码中某些方法的性能,所以想到写一个脚本,用来统计所加的日志中的平均耗时,最大耗时,最小耗时等等,这需要保证每行日志都是唯一的,代码中添加日志的方式如下: 为了便于验证,写了一个简单的日志文件 console.log ,内容如下: [root@iZ2ze10u5v2hhw1ezi52suZ shell]# cat consol…
经常在部署tomcat时需要替换配置文件中的ip,find命令批量替换还是很方便的 查找需要替换的ip,看看哪些文件有配置这个ip,执行下面命令: find ./ -type f -regex ".*\.xml\|.*\.js.*\|.*\.properties" | xargs grep "118.190.73.218" 查找完成后进行替换为139.129.208.20,执行下面命令: find ./ -type f -regex ".*\.xml\|.…
文件d.txt如下内容 ggg 1portals: 192.168.5.41:3260werew 2portals: 192.168.5.43:3260 如何把文件d.txt内容变为如下内容 ggg 192.168.5.41:3260werew 192.168.5.43:3260 解题思路: [root@localhost study]# awk '/port/{print a" "$2}{a=$1}' d.txt ggg 192.168.5.41:3260werew 192.168.…
删除某一目录下文件,只保留最新的几个 #!/bin/bash #保留文件数 ReservedNum= FileDir=/home/dev/saas_test/testcases/report/html #*.html为文件类型,不写查找所有文件 FileNum=$(ls -l $FileDir/*.html |grep ^- |wc -l) while(( FileNum > ReservedNum)) do OldFile=$(ls -rt $FileDir/*.html| head -1)…
private void button1_Click(object sender, EventArgs e) { var txt1 = "E:\\Temp\\local"; string[] files = Directory.GetFiles(txt1, "*.txt"); foreach (string file in files) { execFile(file); } } void execFile(string file) { ; var eType =…
===================================================== 参考链接 Python 文本文件内容批量抽取:https://blog.csdn.net/qq_22885109/article/details/80819916 python实现根据指定字符截取对应的行的内容:https://blog.csdn.net/xqn2017/article/details/78206988 判断字符串是否为空::https://blog.csdn.net/qi…