6

I'm trying to remove a single command from TCSH history on RHEL 6, but couldn't find a way. I tried out the following Bash command as in [1], it didn't work.

history -d <line_number>

How can I achieve this?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227

1 Answers1

9

I don't use tcsh, but perusing the man page suggests:

  1. save current history with history -S
  2. edit the history file to remove the offending command with vi ~/.history (or vi $histfile, if you've overridden the default).
  3. clear history with history -c
  4. load revised history with history -L

Read your tcsh man page for the various details.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
glenn jackman
  • 84,176
  • 15
  • 116
  • 168
  • I opened a tcsh shell to test these commands; they worked as advertised. `101 14:40 history -L 102 14:39 echo command here 104 14:39 history -S` -- where I manually edited out command #103 from ~/.history. – Jeff Schaller Jun 20 '18 at 18:43
  • Those commands worked for me, I'm accepting your answer. –  Jun 21 '18 at 08:16