STDOUT得到的字串作命令執行

2021-07-01 21:56:15 字數 540 閱讀 2382

學習selinux時,查閱/var/log/messages資訊的時候提示「run sealert -l **********************"('*'代表一串字串)。

因為"sealert -l **********************"過長,所以想通過管道提取該命令串,再執行。

通過命令:

cat /var/log/messages | grep setroubleshoot | tail -n 1 | cut -d '.' -f4 | cut -d ' ' -f3,4,5

成功提取出該命令,但是不知道如何將該stdout作命令執行。

解決方案:

通過查閱資料,發現xargs命令可作引數代換。於是想stdout僅輸出」-l **********************",再結合xargs執行該命令。

命令如下:

cat /var/log/messages | grep setroubleshoot | tail -n 1 | cut -d '.' -f4 | cut -d ' ' -f4,5 | xargs sealert

得到指定字串列表中,指定個數的字串

if exists select from dbo.sysobjects where id object id n dbo f split and xtype in n fn n if n tf drop function dbo f split go 得到字串列表指定位置的字元 可以自定義字串列表...

得到指定字串列表中,指定個數的字串

if exists select from dbo.sysobjects where id object id n dbo f split and xtype in n fn n if n tf drop function dbo f split go 得到字串列表指定位置的字元 可以自定義字串列表...

得到指定字串列表中,指定個數的字串

if exists select from dbo.sysobjects where id object id n dbo f split and xtype in n fn n if n tf drop function dbo f split go 得到字串列表指定位置的字元 可以自定義字串列表...