1

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?
    – FedKad
    Sep 24, 2019 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
    – code-8
    Sep 24, 2019 at 19:52

1 Answer 1

2

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
    – code-8
    Sep 25, 2019 at 21:09
  • @kyo : Can you try history | sort -u -b -k2,2 ?
    – FedKad
    Sep 27, 2019 at 19:52
  • that seems working fine.
    – code-8
    Sep 30, 2019 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .