ログshowコマンドの出力操作

ログshowコマンドの出力操作

以下はmacOS high Sierraで実行されるコマンドです。

**`Command`**

 log show --info --predicate 'process="jamf" and eventMessage contains "Informing the JSS about login for user"' --start 2019-04-25|awk '{printf "%s %s %s %s %s %s %s %s %s %s %s %s %s \n", $1,$2,$4,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18}'|sed '1d'|column -t -s " "|grep -v "Informing  the  JSS  about  login  for  user  root"

Output:

 log: warning: ./system_logs.logarchive present but reading from system log store.

2019-04-25  09:49:26.843101+0530  Default  jamf:  [com.jamf.management.binary:all]  Informing  the  JSS  about  login  for  user  swastibhushandeb
2019-04-25  20:14:47.928848+0530  Default  jamf:  [com.jamf.management.binary:all]  Informing  the  JSS  about  login  for  user  swastibhushandeb

Desired Output:

2019-04-25  09:49:26.843101+0530  Default  jamf:  [com.jamf.management.binary:all]  Local Login for user  swastibhushandeb 
2019-04-25  20:14:47.928848+0530  Default  jamf:  [com.jamf.management.binary:all]  Local Login for user  swastibhushandeb 

私が知っている限り、Informing the JSS about login for user swastibhushandeb次のコマンドを使用して ""を置き換えることができます。sed 's/Informing the JSS about login for user swastibhushandeb/Local Login for user swastibhushandeb/'

  1. ただし、ユーザー名はシナリオによって異なる可能性があるため、"Informing the JSS about login for user swastibhushandeb"ユーザー名を含む特定のフィールドを選択して置き換える方法は?
  2. 以下を使用して列ヘッダーを出力に挿入する方法awk begin

改善点/サンプルコードの提案を歓迎します。

ベストアンサー1

最初の質問に対する答えは次のとおりです。

sed 's/Informing  the  JSS  about  login  for  user/Local Login for user'

正しいコマンドを提案しましたが、置き換える必要はありませんusername。別の単語に置き換えてください。

2番目の質問にはより詳細な情報を提供する必要があります。

おすすめ記事