0

I am running only Linux on a Mac computer. I am working on the TTY terminal only as I have not installed GUI yet. Right now, history gives me this:

$ history
    1  2016-10-05 00:25:36 grape instance status
    2  2016-10-05 00:26:00 history
    3  2016-10-05 00:27:10 history | more
    4  2016-10-05 00:44:56 history | sed 's/.[ ]*.[0-9]*.[ ]*//' | uniq | grep -i "heroku"
    5  2016-10-05 00:45:36 history | sed 's/.[ ]*.[0-9]*.[ ]*//' | uniq
    6  2016-10-05 00:49:29 history | sed 's/.[ ]*.[0-9]*.[ ]*//'
    7  2016-10-05 00:51:32 history | cut -d " " -f7-1000 |
    8  2016-10-05 00:51:36 history | cut -d " " -f7-1000
    9  2016-10-05 00:56:54 history

I want to get rid of the timestamps and index number. I want just the commands. As you can see from the history, I tried solution of this question: history | sed 's/.[ ]*.[0-9]*.[ ]*//' | uniq | grep -i "heroku", but it does not seem to work on TTY terminal. It removes the index numbers, but the timestamp is still there. Output is as below (I omitted the uniq and grep command as i don't need them):

$ history | sed 's/.[ ]*.[0-9]*.[ ]*//'
2016-10-05 00:25:36 grape instance status
2016-10-05 00:26:00 history
2016-10-05 00:27:10 history | more
2016-10-05 00:44:56 history | sed 's/.[ ]*.[0-9]*.[ ]*//' | uniq | grep -i "heroku"
2016-10-05 00:45:36 history | sed 's/.[ ]*.[0-9]*.[ ]*//' | uniq
2016-10-05 00:49:29 history | sed 's/.[ ]*.[0-9]*.[ ]*//'
2016-10-05 00:51:32 history | cut -d " " -f7-1000 |
2016-10-05 00:51:36 history | cut -d " " -f7-1000
2016-10-05 00:56:54 history
2016-10-05 00:59:04 history | sed 's/.[ ]*.[0-9]*.[ ]*//'

I even tried running history | cut -d " " -f7-1000 | sort (from the comments in the linked question) but it does not remove the timestamps either.

I also tried running first solution from the link: HISTTIMEFORMAT ="";, but I get an error saying

HISTTIMEFORMAT: command not found

Is it possible to get history without timestamps in TTY?

EDIT: The solution from this question did not work for me initially because of a single space. (Given solution was HISTTIMEFORMAT =""; but the space had to be removed to make it work. Otherwise I wouldn't have asked this duplicate question.

dc95
  • 123
  • 10
  • 1
    Try HISTTIMEFORMAT= or HISTTIMEFORMAT="" (note: no space allowed between the HISTTIMEFORMAT and the = sign) – steeldriver Oct 05 '16 at 01:12
  • @steeldriver Hey, that worked! Can you post it as answer so I can tick it? – dc95 Oct 05 '16 at 01:36
  • 2
    IMHO it really is a duplicate of the question you linked - although the answers there could use some edits – steeldriver Oct 05 '16 at 01:44
  • Please close this question as it has been answered. Also, this is a duplicate due to the same solution being given in the question you linked. – TheOdd Oct 05 '16 at 05:18
  • The problem isn't that you're using TTY - the answers to the other question just do not work. There you are only asking sed to match one set of numbers... For what you have there you could probably do something like sed 's/^.*:[0-9]*:[0-9]*\s//' but obviously unsetting HISTTIMEFORMAT is better... – Zanna Oct 05 '16 at 06:48

0 Answers0