1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

bashでhistoryの重複を削除する方法

Posted at

既存のhistoryから重複を削除

# 現在のhistoryから重複を削除したunduped_historyファイルを作成
nl ~/.bash_history | sort -k 2  -k 1,1nr| uniq -f 1 | sort -n | cut -f 2 > unduped_history

# 重複を除去したhistoryを現在のhistoryと入れ替え
cp unduped_history ~/.bash_history

# 邪魔なので削除
rm unduped_history

今後もhistoryに重複を残さない方法

.bashrcに以下を追記

HISTCONTROL=erasedups

.bashrcを更新

source .bashrc
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?