0

I ran this command

history | cut -c 8-

It listed all the history commands as expected without line numbers.

I'm wondering if there is a way to list only unique one.

I've tried

history | cut -c 8- | sort -u

doesn't seem to work.

2
  • Unique in what respect? – FedonKadifeli Sep 24 '19 at 18:42
  • Trying to avoid seeing same commands in history. I’m trying to documents what I did for the pass months and see a lot of commands is confusing – cyb3rZ Sep 24 '19 at 19:52
0

To get the names of the commands only, you can use this:

history | cut -f4 -d\  | sort -u

Or for better results, you can use this:

history | sort -u -b -k2,2
3
  • That command showed a lot of number – cyb3rZ Sep 25 '19 at 21:09
  • @kyo : Can you try history | sort -u -b -k2,2 ? – FedonKadifeli Sep 27 '19 at 19:52
  • that seems working fine. – cyb3rZ Sep 30 '19 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.