bash
允许使用 运行 bash 脚本bash somescript
,python
使用python3 somescript
. 或者,使用正确的 shebang,我可以直接使用./somescript
.
对于二进制程序,我可以运行它们,就像./someprogram
它们具有可执行权限集一样。
但是是否有 GNU/Linux 命令来运行二进制可执行文件,例如run,如:run someprogram
?
典型的用例是:某个程序位于带有noexec
集合的分区中。这样的run命令将能够运行 myprogram,就好像它位于安装了run 的分区中一样,就像usr/bin
安装了该exec
标志一样。
备注:这不是chmod
问题。某个程序已exec
设置权限。
假设我想过滤日志以针对每个用户 ID 使用不同的文件,我可以为每个 uid 编写一条规则,如下所示:
if $msg contains 'uid=500' then /var/log/uid/500
if $msg contains 'uid=501' then /var/log/uid/501
if $msg contains 'uid=502' then /var/log/uid/502
Run Code Online (Sandbox Code Playgroud)
我想通过使用正则表达式捕获来编写一行,如下所示:
if $msg contains 'uid=\([0-9]+\)' then /var/log/uid/\1
Run Code Online (Sandbox Code Playgroud)
请问可以吗?