使用GREP/SED/等提取括号?
我正在尝试使用以下管道命令来获取PHP-FPM的文件位置:
ps aux | grep php-fpm | grep master
结果:
root 80 0.0 0.6 334912 26072 ? Ss 14:18 0:00 php-fpm: master process (/root/.symfony/php/2b1b88a9c9ed1cd796c66569d386096e96bbe2bc/fpm-7.3.33.ini)
但是我仍然需要在支架之间提取文件路径,无法完全弄清楚,输入字符串正在抱怨非法令牌..
RESULT_FROM_ABOVE | grep -o '^[\(^.\)]*'
bash:语法错误接近意外令牌`('
这是不起作用的,但应该给出我要实现的目标的想法。
我需要在我试图应用的最后一个GREP之前逃脱result_from_above t找不到解决方案
?
I am trying to obtain a file location for PHP-FPM, using the following piped commands works:
ps aux | grep php-fpm | grep master
Results:
root 80 0.0 0.6 334912 26072 ? Ss 14:18 0:00 php-fpm: master process (/root/.symfony/php/2b1b88a9c9ed1cd796c66569d386096e96bbe2bc/fpm-7.3.33.ini)
However I still need to extract the file path between the brackets, can't quite figure it out, the input string is complaining about illegal tokens..
RESULT_FROM_ABOVE | grep -o '^[\(^.\)]*'
bash: syntax error near unexpected token `('
This doesn't work but should give the gist of the idea of what I am trying to achieve.
I need to escape the RESULT_FROM_ABOVE before the final grep I am trying to apply and I can't find any solution.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置一个变量来模拟
PS/GREP/GREP
(pgg_out
)和ps
(ps_out> ps_out
)输出:将当前
PS/GREP/GREP
输出到sed
:消除OP的当前
GREP
调用并输送PS
输出输出到awk
:Setup a couple variables to simulate the
ps/grep/grep
(pgg_out
) andps
(ps_out
) output:Piping the current
ps/grep/grep
output tosed
:Eliminating OP's current
grep
calls and piping theps
output toawk
: