<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.linuxsa.org/index.php?action=history&amp;feed=atom&amp;title=%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%91%BD%E4%BB%A4%E4%B9%8Bhistory</id>
	<title>每天一命令之history - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.linuxsa.org/index.php?action=history&amp;feed=atom&amp;title=%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%91%BD%E4%BB%A4%E4%B9%8Bhistory"/>
	<link rel="alternate" type="text/html" href="https://wiki.linuxsa.org/index.php?title=%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%91%BD%E4%BB%A4%E4%B9%8Bhistory&amp;action=history"/>
	<updated>2026-04-17T02:22:34Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.linuxsa.org/index.php?title=%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%91%BD%E4%BB%A4%E4%B9%8Bhistory&amp;diff=1346&amp;oldid=prev</id>
		<title>Evan：​/* see also */</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxsa.org/index.php?title=%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%91%BD%E4%BB%A4%E4%B9%8Bhistory&amp;diff=1346&amp;oldid=prev"/>
		<updated>2022-09-22T02:09:03Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;see also&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[category:devops]][[category:linux]] [[category:shell]]&lt;br /&gt;
=history=&lt;br /&gt;
==DESCRIPTION==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
       Many  programs  read input from the user a line at a time.  The GNU History library is able to keep track of those lines,&lt;br /&gt;
       associate arbitrary data with each line, and utilize information from previous lines in composing new ones.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=OPTIONS=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   -c	清空当前历史命令 clear the history list by deleting all of the entries&lt;br /&gt;
  -d offset	删除历史记录中第offset个命令 delete the history entry at position OFFSET. Negative&lt;br /&gt;
    		offsets count back from the end of the history list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-N: 显示历史记录中最近的N个记录；&lt;br /&gt;
&lt;br /&gt;
-a：将历史命令缓冲区中命令写入历史命令文件中；&lt;br /&gt;
-r：将历史命令文件中的命令读入当前历史命令缓冲区；&lt;br /&gt;
-w：将当前历史命令缓冲区命令写入历史命令文件中;&lt;br /&gt;
&lt;br /&gt;
-n&amp;lt;filename&amp;gt;：读取指定文件&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=部分删除操作 清除命令执行操作的历史记录=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.vim ~/.bash_history&lt;br /&gt;
该文件即为历史记录存储文件，我们随意修改&lt;br /&gt;
&lt;br /&gt;
2.修改后再次 history 查看，发现并没有变化。原因：缓存&lt;br /&gt;
执行：history -r&lt;br /&gt;
读取历史文件并将其内容添加到历史记录中，即重置文件里的内容到内存中，完成修改！&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=完全清除命令执行操作的历史记录=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.清理历史记录（只是清理了表层，可在.bash_history找到回）&lt;br /&gt;
history -c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2.清理记录历史的记录文件内容&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot; &amp;quot; &amp;gt; .bash_history &lt;br /&gt;
echo &amp;gt;  ~/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=see also=&lt;br /&gt;
&lt;br /&gt;
[https://linuxtoy.org/archives/history-command-usage-examples.html History（历史）命令用法 15 例]&lt;br /&gt;
[https://blog.csdn.net/GX_1_11_real/article/details/80364246 Linux中history配置及使用技巧]&lt;br /&gt;
&lt;br /&gt;
[https://www.cnblogs.com/ljs05/p/7374707.html history命令]&lt;/div&gt;</summary>
		<author><name>Evan</name></author>
	</entry>
</feed>