clear history from shell
Tom H
tomh0665 at gmail.com
Mon May 16 14:29:51 UTC 2016
On Mon, May 16, 2016 at 3:57 PM, Karl Auer <kauer at biplane.com.au> wrote:
> On Mon, 2016-05-16 at 13:18 +0100, Grizzly wrote:
>>
>> I have a simple script,
>>
>> #!/bin/sh
>> history -c && history -w && exit
>>
>> each part was tested manually and the whole line has also been
>> tested, but once I run the script it returns
>>
>> "3: Scripts/myclean.sh: history: not found"
>
> You changed the shell from bash (or dash) to sh in the first line of
> your script. Change it to /bin/bash and your script will run.
sh is dash by default in Ubuntu and, you're right, it dosen't have the
bash "history" builtin. Changing the shebang will fix the problem.
I don't use this command so I looked it up:
$ help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or
history -ps arg [arg...]
Display or manipulate the history list.
Display the history list with line numbers, prefixing each modified
entry with a `*'. An argument of N lists only the last N entries.
Options:
-c clear the history list by deleting all of the entries
-d offset delete the history entry at offset OFFSET.
-a append history lines from this session to the history file
-n read all history lines not already read from the history file
-r read the history file and append the contents to the history
list
-w write the current history to the history file
and append them to the history list
-p perform history expansion on each ARG and display the result
without storing it in the history list
-s append the ARGs to the history list as a single entry
If FILENAME is given, it is used as the history file. Otherwise,
if $HISTFILE has a value, that is used, else ~/.bash_history.
If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry. No time stamps are printed otherwise.
Exit Status:
Returns success unless an invalid option is given or an error occurs.
Is "history -w" necessary?
More information about the ubuntu-users
mailing list