Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 用于搜索文本模式的Unix命令_Regex_Unix_Command_Pattern Matching - Fatal编程技术网

Regex 用于搜索文本模式的Unix命令

Regex 用于搜索文本模式的Unix命令,regex,unix,command,pattern-matching,Regex,Unix,Command,Pattern Matching,我试图在我的Unix日志文件框中搜索下面这样的文本,即它以文本“TransactionTime:”开头,然后在一些字符后面有一个括号[里面有一些数字,然后以结尾] 例如 TransactionTime: 1407258546484 -> 1407258552848 [ 6364 ] 我尝试了几种组合,用Grep在我的unix文件中搜索这些行,但它对我没有帮助,我如何在控制台或输出文件中搜索和打印所有这些行 文件名为TransactionPerformance.log 谢谢您可以尝试下面

我试图在我的Unix日志文件框中搜索下面这样的文本,即它以文本“TransactionTime:”开头,然后在一些字符后面有一个括号[里面有一些数字,然后以结尾]

例如

TransactionTime: 1407258546484 -> 1407258552848 [ 6364 ] 
我尝试了几种组合,用Grep在我的unix文件中搜索这些行,但它对我没有帮助,我如何在控制台或输出文件中搜索和打印所有这些行

文件名为TransactionPerformance.log


谢谢

您可以尝试下面的grep命令,该命令使用
-p
(Perl regexp)参数

grep -P '^TransactionTime:.*?\[[\s\d]+\]' *

为了选择,我会尝试
ack
grep的改进版本->


你想提取任何文本还是只搜索整行?
ack '^TransactionTime:.*\[ [\d]+ \]' *