对日志文件进行组计数排序

SQL: SELECT COUNT(x), x FROM y GROUP BY x ORDER BY count DESC;
BASH:最后一种类型的临时变量: $A=$(
你想要的文件: FILE=/var/log/myfile.log
将文件转储到流: cat $FILE |
剪下你想要计数的位数: perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' |
得到一个独特的清单: sort -u |
对于流中的每个行/值执行以下操作: while read LINE; do
将与当前值匹配的所有行转储到内部流: grep "$LINE" $FILE |
算他们: wc -l |
清理wc的输出并删除stdout上的值: perl -p -e 's/[^0-9]+//g';
将当前值删除到stdout: echo -e "\t$LINE";
完成外部流上的每个值操作: done;
完成输出到temp var: );
将temp var转储到管道: echo "$A" |
以数字方式对列表进行反向排序: sort -nr
.

0

linux命令:A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nr -nr "$A"|sort done;);echo "\t$LINE"; -e echo 's/[^0-9]+//g'; -e -p perl | -l wc | $FILE "$LINE" grep do LINE; read while | -u sort | 's/.*,([A-Z]+)[\:\+].*/$1/g' -e -p perl | $FILE cat A=$(FILE=/var/log/myfile.log; A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nrrootopen.com
linux命令:A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nr -nr "$A"|sort done;);echo "\t$LINE"; -e echo 's/[^0-9]+//g'; -e -p perl | -l wc | $FILE "$LINE" grep do LINE; read while | -u sort | 's/.*,([A-Z]+)[\:\+].*/$1/g' -e -p perl | $FILE cat A=$(FILE=/var/log/myfile.log; A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nrrootopen.com
wctk 2018-12-22 22:00:59
输出
linux命令:cat 详解

评论

相关推荐

linux命令:cat foo.zip | jar xv xv jar | foo.zip cat cat foo.zip | jar xvrootopen.com
linux命令:cat foo.zip | jar xv xv jar | foo.zip cat cat foo.zip | jar xvrootopen.com
.

cat -n 将为文件的所有行编号

linux命令:cat -n /path/to/file | less less | /path/to/file -n cat cat -n /path/to/file | lessrootopen.com
linux命令:cat -n /path/to/file | less less | /path/to/file -n cat cat -n /path/to/file | lessrootopen.com
.

linux命令:cat url.list | parallel -j 8 wget -O {#}.html {} {} {#}.html -O wget 8 -j parallel | url.list cat cat url.list | parallel -j 8 wget -O {#}.html {}rootopen.com
linux命令:cat url.list | parallel -j 8 wget -O {#}.html {} {} {#}.html -O wget 8 -j parallel | url.list cat cat url.list | parallel -j 8 wget -O {#}.html {}rootopen.com
.

perl正则表达式模式m/\w+/g将匹配连续的非单词字符,从而生成源字符串中所有单词的列表 map("$_\n", @list) 转换列表,在每个元素的末尾附加换行符 tr A-Z a-z 将大写字母转换为小写 在awk中,length($1) == 4 {print}表示:对于匹配过滤条件“第一列的长度为4”的行,执行代码块

linux命令:cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}' {print}' 4 == 'length($1) awk | uniq | sort | a-z A-Z tr | m/\w+/g);' map("$_\n", 'print -ne perl | ipsum.txt cat cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}'rootopen.com
linux命令:cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}' {print}' 4 == 'length($1) awk | uniq | sort | a-z A-Z tr | m/\w+/g);' map("$_\n", 'print -ne perl | ipsum.txt cat cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}'rootopen.com
.

npm install json-to-js

linux命令:cat data.json | json-to-js | pbcopy pbcopy | json-to-js | data.json cat cat data.json | json-to-js | pbcopyrootopen.com
linux命令:cat data.json | json-to-js | pbcopy pbcopy | json-to-js | data.json cat cat data.json | json-to-js | pbcopyrootopen.com
.

cat:将文件打印到标准输出 colrm:从文件中删除选定的列 第一个参数:从某行开始删除, 第二个参数:删除某列

linux命令:cat /tmp/log.data | colrm 1 155 | colrm 60 300 300 60 colrm | 155 1 colrm | /tmp/log.data cat cat /tmp/log.data | colrm 1 155 | colrm 60 300rootopen.com
linux命令:cat /tmp/log.data | colrm 1 155 | colrm 60 300 300 60 colrm | 155 1 colrm | /tmp/log.data cat cat /tmp/log.data | colrm 1 155 | colrm 60 300rootopen.com
.

linux命令:cat file.json | jq jq | file.json cat cat file.json | jqrootopen.com
linux命令:cat file.json | jq jq | file.json cat cat file.json | jqrootopen.com
.

sort命令用于对指定文件或stdin中的文本行进行排序

linux命令:cat words.txt words.txt cat cat words.txtrootopen.com
linux命令:cat words.txt words.txt cat cat words.txtrootopen.com
.

linux命令:cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; done done +%Y%m%d_%H%M%S`.sql.gz; $HOME/backups/${db}_`date > -9 gzip | ${db}" -p\$MYSQL_ROOT_PASSWORD -uroot "mysqldump -c bash $container_name exec docker do db; read while | databases.txt cat cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; donerootopen.com
linux命令:cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; done done +%Y%m%d_%H%M%S`.sql.gz; $HOME/backups/${db}_`date > -9 gzip | ${db}" -p\$MYSQL_ROOT_PASSWORD -uroot "mysqldump -c bash $container_name exec docker do db; read while | databases.txt cat cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; donerootopen.com
.

我们可以看到TAB空间填充了' ^ I '字符。

linux命令:cat -T test test -T cat cat -T testrootopen.com
linux命令:cat -T test test -T cat cat -T testrootopen.com
.

你可以看到-e选项,$显示在行尾,如果段落之间有任何间隙,则显示$。 此选项对于在一行中挤出多行非常有用

linux命令:cat -e test test -e cat cat -e testrootopen.com
linux命令:cat -e test test -e cat cat -e testrootopen.com
.

使用-n选项,您可以在输出终端中看到文件song.txt的行号。

linux命令:cat -n song.txt song.txt -n cat cat -n song.txtrootopen.com
linux命令:cat -n song.txt song.txt -n cat cat -n song.txtrootopen.com
.

如果具有大量不适合输出终端和屏幕的内容的文件非常快速地滚动,我们可以使用cat命令越来越少地使用参数

linux命令:cat song.txt | more cat song.txt | less less | song.txt more cat | song.txt cat cat song.txt | more cat song.txt | lessrootopen.com
linux命令:cat song.txt | more cat song.txt | less less | song.txt more cat | song.txt cat cat song.txt | more cat song.txt | lessrootopen.com
.

我们将使用以下命令创建一个名为test2的文件

linux命令:cat >test2 >test2 cat cat >test2rootopen.com
linux命令:cat >test2 >test2 cat cat >test2rootopen.com
.

在下面的例子中,它将显示终端中test和test1文件的内容

linux命令:cat test test1 test1 test cat cat test test1rootopen.com
linux命令:cat test test1 test1 test cat cat test test1rootopen.com
.

在下面的示例中,它将显示/etc/passwd文件的内容

linux命令:cat /etc/passwd /etc/passwd cat cat /etc/passwdrootopen.com
linux命令:cat /etc/passwd /etc/passwd cat cat /etc/passwdrootopen.com
.

linux命令:cat file.txt file.txt cat cat file.txtrootopen.com
linux命令:cat file.txt file.txt cat cat file.txtrootopen.com
.

linux命令:cat /proc/meminfo /proc/meminfo cat cat /proc/meminforootopen.com
linux命令:cat /proc/meminfo /proc/meminfo cat cat /proc/meminforootopen.com
.

您需要使用aws ec2 describe实例来获取JSON文件。

linux命令:cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv' join(";"))]|@csv' | tostring] .Value),([.InstanceId| | =="Name") select(.Key | .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] [.PrivateIpAddress, | '.Reservations[].Instances[] -r jq | aws.json cat cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'rootopen.com
linux命令:cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv' join(";"))]|@csv' | tostring] .Value),([.InstanceId| | =="Name") select(.Key | .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] [.PrivateIpAddress, | '.Reservations[].Instances[] -r jq | aws.json cat cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'rootopen.com
.

1.我们先往文件A输入一些包含控制符的内容 $ cat > A CTRL-v I CTRL-O Love esc-b CTRL-D 2.如果我们使用cat来查看文件,我们只看到普通文本: $ cat A I Love 3.要查看文件中的实际内容,请使用-v $ cat -v A ^V I ^O Love ^[b

linux命令:cat -v A A -v cat cat -v Arootopen.com
linux命令:cat -v A A -v cat cat -v Arootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令