各行の最初の部分に色を割り当てます。

各行の最初の部分に色を割り当てます。

次のチャット履歴があります。

(15:12:56) rubo77: mist migration
(15:05:22) hans: ist hugo da?
(15:36:13) rubo77: test
(13:30:15) rubo77: what are the access data?
(15:06:38) [email protected]: user :  [email protected] (https://somewhere.de:8080/index.php#)
(15:06:38) [email protected]: password :  test

sedユーザー名を別の色に変更するにはどうすればよいですか?

それともこれより簡単なツールがありますかsed

ベストアンサー1

以下を使用できます。

sed 's/) \(.*\):/) \x1b[31m\1\x1b[0m:/'

たとえば、

cat 1| sed 's/) \(.*\):/) \x1b[31m\1\x1b[0m:/'

バージョン2:

COLOR=32
sed 's/) \(.*\):/) \x1b['${COLOR}'m\1\x1b[0m:/'

色番号を変更できます。

バージョン 3:

COLOR=32
sed 's/) \([[:alpha:][:digit:][:space:]@\.]*\):/) \x1b['${COLOR}'m\1\x1b[0m:/1'

おすすめ記事