当前位置:网站首页>Use PHP to count command line calls on your computer
Use PHP to count command line calls on your computer
2022-06-13 03:14:00 【wks19891215】
<?php
exec("cat ~/.zsh_history",$data);
exec("cat ~/.bash_history",$data);
foreach ($data as $str)
{
$str = preg_replace('/[0-9]|:|;/', "", $str);
$str=trim($str);
$pattern ='/^[a-z]+/';
preg_match($pattern,$str,$match);
$tmp = array_shift($match);
if($tmp!==NULL)
{
$buff[] = $tmp;
}
}
$buff = array_count_values($buff);
asort($buff);
var_dump($buff);
?>
In the development machine mac Upper test passed ~ And in the virtual machine centos Failed on , Because on the virtual machine php Safe mode is not turned off .
PS: Regular expressions are so powerful !
边栏推荐
- Control scanner in Delphi
- Pytorch record: pytorch variables parameter and buffer. self. register_ buffer()、self. register_ parameter()
- Linked list: the first coincident node of two linked lists
- Redis server configuration
- Querywrapper constructor method
- Hash table: whether alien languages are sorted
- Linked list: orderly circular linked list
- Age anxiety? How to view the 35 year old programmer career crisis?
- On the career crisis of programmers at the age of 35
- How to write product requirements documents
猜你喜欢
Six special GPU products for domestic aircraft passed the appraisal and review
二叉樹初始化代碼
【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
MySQL index optimization (4)
Few-shot Unsupervised Domain Adaptation with Image-to-Class Sparse Similarity Encoding
C simple understanding - arrays and sets
[JVM Series 2] runtime data area
【 enregistrement pytorch】 paramètre et tampon des variables pytorch. Self. Register Buffer (), self. Register Paramètre ()
Linked lists: rearranging linked lists
Linked list: palindrome linked list
随机推荐
Control scanner in Delphi
MySQL transactions and locks (V)
Es and kibana deployment and setup
Explain tool and index optimization (II)
2022.05.29
Delete the number of a range in the linked list
Ijkplayer source code - choose soft decoding or hard decoding
技术博客,经验分享宝典
Stack information, GC statistics
[JVM Series 5] JVM tuning instance
[synchronization function] version 2.0.16-19 has the update of synchronization function repair, but the problem has not been solved
Linked list: the entry node of the link in the linked list
Redis server configuration
. New features in net 6.0 _ What's new in net 6.0
Exercise 8-3 rotate array right
Ijkplayer source code - rendering
Prometheus node_exporter安装并注册为服务
Level II C preparation -- basic concepts of program design
Mongodb distributed cluster deployment process
六款国产飞机专用GPU产品通过鉴定审查