awk

linux四剑客常用命令汇总

99封情书 提交于 2020-02-26 01:59:24
**四剑客常用命令汇总** 1.find find path -option [ -print ] [ -exec -ok command ] {} \ (find 查找路径 -type f/d -name ..... -size 1k/M -mtime/atime/ctime +-9 文件) find -type/-perm/-empty/ find /tmp -type f -name "*.tmp" -exec rm -rf '{}' \; find / -type f -name test.txt -size 10k -mtime find . -type f -name ..... -exec rm -rf {} \;或者|xargs rm -rf {} 2.grep grep -v grep -c grep grep -e = egrep egrep --color "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" 3.sed sed -i 4.awk awk -F: awk -f awk -v awk -F: '{print $1":"$NF}' :""表示添加的内容 ifconfig | grep "inet addr:"|grep -v "127.0.0.1"|awk '{print $2}'|awk 来源:

Shell编程之awk工具

风格不统一 提交于 2020-02-26 01:22:19
一、awk介绍 1.awk概述 2.awk能干啥? 二、awk使用方式 1.==命令行模式使用== 1)语法结构 2)常用选项介绍 3)=='==命名部分说明=='== 2.脚本模式使用 1)脚本编写 2)脚本执行 三、 awk内部相关变量 1、==常用内置变量举例== 2、内置变量分隔符举例 四、 awk工作原理 五、awk使用进阶 1.格式化输出print和printf 2.awk变量定义 3.awk中BEGIN...END使用 1)举例说明1 2)举例说明2 4.awk和正则的综合运用 1)举例说明 5.课堂练习 6.awk的脚本编程 1)流程控制语句 2)循环语句 7.awk算数运算 六、awk统计案例 1、统计系统中各种类型的shell 2、统计网站访问状态 3、统计访问网站的每个IP的数量 4、统计网站日志中PV量 一、awk介绍 1. awk概述 awk是一种==编程语言==,主要用于在linux/unix下对==文本和数据==进行处理,是linux/unix下的一个工具。数据可以来自标准输入、一个或多个文件,或其它命令的输出。 awk的处理文本和数据的方式: ==逐行扫描==文件 ,默认从第一行到最后一行,寻找匹配的==特定模式==的行,并在这些行上进行你想要的操作。 awk分别代表其作者姓氏的第一个字母。因为它的作者是三个人,分别是Alfred Aho、Brian

match everything up to first '/' after a specific pattern

家住魔仙堡 提交于 2020-02-25 04:46:29
问题 Trying to do this within a bash script using sed regex on macos. I have a file with directory listings of an external drive. /Volumes/WD/A/Some Learning/Learning Is Great/ /Volumes/WD/A/Some Deeper/Learning Is Great/Another Learning Opportunity/ /Volumes/WD/B/More Things Here/Great Learning/ /Volumes/WD/B/More Things/ I want to search and return the top-most directory matching various patterns. If you search for 'Learning' the output should be: /Volumes/WD/A/Some Learning/ /Volumes/WD/A/Some

web安全杂记

拥有回忆 提交于 2020-02-24 21:07:03
session防御方法 1、每当用户登陆的时候就进行重置sessionID 2、sessionID闲置过久时,进行重置sessionID 3、 大部分防止会话劫持的方法对会话固定攻击同样有效。如设置HttpOnly,关闭透明化Session ID,User-Agent验证,Token校验等。 防御方法: 1、 更改Session名称。PHP中Session的默认名称是PHPSESSID,此变量会保存在Cookie中,如果攻击者不分析站点,就不能猜到Session名称,阻挡部分攻击。 2、 关闭透明化Session ID。透明化Session ID指当浏览器中的Http请求没有使用Cookie来存放Session ID时,Session ID则使用URL来传递。 3、 设置HttpOnly。通过设置Cookie的HttpOnly为true,可以防止客户端脚本访问这个Cookie,从而有效的防止XSS攻击。 4、 关闭所有phpinfo类dump request信息的页面。 5、 使用User-Agent检测请求的一致性。但有专家警告不要依赖于检查User-Agent的一致性。这是因为服务器群集中的HTTP代理服务器会对User-Agent进行编辑,而本群集中的多个代理服务器在编辑该值时可能会不一致。 6、 加入Token校验。同样是用于检测请求的一致性,给攻击者制造一些麻烦

Filling empty spaces in a CSV file

假如想象 提交于 2020-02-23 21:57:57
问题 I have a CSV file where some columns are empty such as oski14,safe,0,13,53,4 oski15,Unknow,,,,0 oski16,Unknow,,,,0 oski17,Unknow,,,,0 oski18,unsafe,0.55,,1,2 oski19,unsafe,0.12,4,,56 How do I replace all the empty columns with the word "empty". I have tried using awk(which is a command I am learning to use). I want to have oski14,safe,0,13,53,4 oski15,Unknow,empty,empty,empty,0 oski16,Unknow,empty,empty,empty,0 oski17,Unknow,empty,empty,empty,0 oski18,unsafe,0.55,empty,1,2 oski19,unsafe,0.12

Filling empty spaces in a CSV file

人盡茶涼 提交于 2020-02-23 21:57:34
问题 I have a CSV file where some columns are empty such as oski14,safe,0,13,53,4 oski15,Unknow,,,,0 oski16,Unknow,,,,0 oski17,Unknow,,,,0 oski18,unsafe,0.55,,1,2 oski19,unsafe,0.12,4,,56 How do I replace all the empty columns with the word "empty". I have tried using awk(which is a command I am learning to use). I want to have oski14,safe,0,13,53,4 oski15,Unknow,empty,empty,empty,0 oski16,Unknow,empty,empty,empty,0 oski17,Unknow,empty,empty,empty,0 oski18,unsafe,0.55,empty,1,2 oski19,unsafe,0.12

How to print a series of words using awk?

微笑、不失礼 提交于 2020-02-21 13:49:42
问题 I know that awk can be used to print only certain words from the output.For example dpkg -l|awk '{print $2}' would print 2nd word from the output of dpkg -l . What I want to do is, print every word after a given word.My command looks like this awk '{printf "%-40s %s\n", $1, $n}' Rather than printing all the words with $n or $0 , I would like to print every word that comes after, say 5th character. How can I do this? EDIT : my complete command is bind -P|grep "can be found"|sort|awk '{printf "

How to print a series of words using awk?

99封情书 提交于 2020-02-21 13:44:11
问题 I know that awk can be used to print only certain words from the output.For example dpkg -l|awk '{print $2}' would print 2nd word from the output of dpkg -l . What I want to do is, print every word after a given word.My command looks like this awk '{printf "%-40s %s\n", $1, $n}' Rather than printing all the words with $n or $0 , I would like to print every word that comes after, say 5th character. How can I do this? EDIT : my complete command is bind -P|grep "can be found"|sort|awk '{printf "

Bash: how to find and break up long lines by inserting continuation character and newline?

与世无争的帅哥 提交于 2020-02-21 13:02:54
问题 I know how to find long lines in a file, using awk or sed: $ awk 'length<=5' foo.txt will print only lines of length <= 5. sed -i '/^.\{5,\}$/d' FILE would delete all lines with more than 5 characters. But how to find long lines and then break them up by inserting the continuation character ('&' in my case) and a newline? Background: I have some fortran code that is generated automatically. Unfortunately, some lines exceed the limit of 132 characters. I want to find them and break them up

grep/sed/awk命令查看指定时间段的日志

╄→尐↘猪︶ㄣ 提交于 2020-02-19 17:19:53
*grep命令 今天遇到研发要求查询定时任务(elastic-job)在14:00-14:40的日志,使用grep命令很方便: 命令: grep '时间' '日志文件名 ' 1、例如查询2020-02-19 14:10到2020-02-19 14:15区间的日志 grep "2020-02-19 14:1[0-5]" dubbo-elastic-job.log 查询日志时间正好截至2020 02-19 14:15 2、例如查询当天10点到11点的日志 grep "2020-02-19 1[0-1] " dubbo-elastic-job.log *sed命令---推荐使用   1、例如查询2020-02-19 14:10到2020-02-19 14:15区间的日志 sed -n '/2020-02-19 14:10:00/,/2020-02-19 14:15:00/p' dubbo-elastic-job.log *awk命令   1、例如查询今天14:10:10 到14:12:59区间的日志,注意时间要用引号 awk '$2>"14:10:10" && $2<"14:12:59"' dubbo-elastic-job.log   注意参数$1和$2的取值,我这里$1是指年月日,$2是指时分秒。    来源: https://www.cnblogs.com/python-wen/p