ターミナル終了時 ~/.bash_history ファイル操作

ターミナル終了時 ~/.bash_history ファイル操作

ファイルで基本的に実行される操作に加えて、端末を閉じるときに次のような~/.bash_history他のタスクを追加したいと思います。

tac ~/.bash_history | awk '!x[$0]++' | tac > /tmp/.bash_history
cat /tmp/.bash_history > ~/.bash_history
rm -f /tmp/.bash_history

これにより、最後の値を維持しながら、「~/.bash_history」ファイルからすべての重複値が削除されます。

どうすればいいですか?

ベストアンサー1

おすすめ記事