100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > windows命令提示符_如何在Windows命令提示符中使用命令历史记录

windows命令提示符_如何在Windows命令提示符中使用命令历史记录

时间:2022-01-22 21:54:49

相关推荐

windows命令提示符_如何在Windows命令提示符中使用命令历史记录

windows命令提示符

The Windows Command Prompt has a built-in history feature, allowing you to quickly view commands you’ve runin the current session. Even better, the Command Prompt offers quite a few keyboard shortcuts and other tricks for working with your command history.

Windows命令提示符具有内置的历史记录功能,使您可以快速查看在当前会话中运行的命令。 更好的是,命令提示符提供了许多键盘快捷键和其他技巧来处理您的命令历史记录。

如何查看命令历史记录 (How to View Your Command History)

To scroll through your command history, you can use these keyboard shortcuts:

要滚动浏览命令历史记录,可以使用以下键盘快捷键:

Up Arrow: Recall the previous command you typed.Press the key repeatedly to walk through your command history.

向上箭头:调出您键入的上一个命令。 反复按该键可浏览命令历史记录。

Down Arrow: Recall the next command you typed. Press the key repeatedly to walk through your command history.

向下箭头:调出您键入的下一个命令。 反复按该键可浏览命令历史记录。

Page Up: Recall the first command you ran in the current Command Prompt session.

Page Up:调出您在当前“命令提示符”会话中运行的第一个命令。

Page Down: Recall the most recent command you ran in the current Command Prompt session.

Page Down:调出您在当前“命令提示符”会话中运行的最新命令。

Esc: Clear the command line.

Esc:清除命令行。

Use these F keys tointeract with your command history:

使用以下F键与您的命令历史记录进行交互:

F7: View your command history as an overlay. Use the up and down arrow keys to select a command and run it. Press Esc to close the overlay without running a command.

F7:以覆盖形式查看命令历史记录。 使用上下箭头键选择一个命令并运行它。 按Esc键可关闭覆盖,而无需运行命令。

F8: Search your command history for a command matching the text on the currentcommand line. So, if you wanted to search for a command that began with “p”, you’d type “p” on the command line and then repeatedly tap F8 to cycle through commands in your history that begin with “p”.

F8:在命令历史记录中搜索与当前命令行上的文本匹配的命令。 因此,如果您要搜索以“ p”开头的命令,请在命令行上键入“ p”,然后反复点按F8键以循环浏览历史记录中以“ p”开头的命令。

F9: Recall a command from your command history by specifying its number in the history buffer. These numbers are display in the F7 overlay window, and begin at 0. So, if you wanted to quickly re-run the first command you ran in the current session, you’d press “F9”, type “0”, and press “Enter”. The command would appear filled in at the prompt and you could press “Enter” once again to run it.

F9:通过在历史记录缓冲区中指定其编号,从命令历史记录中调用命令。 这些数字显示在F7覆盖窗口中,并从0开始。因此,如果要快速重新运行在当前会话中运行的第一个命令,请按“ F9”,键入“ 0”,然后按“输入”。 该命令将显示在提示符处,您可以再次按“ Enter”运行它。

To print a list of your command history in the terminal, run the following command:

要在终端中打印命令历史记录的列表,请运行以下命令:

doskey /history

You’ll see the commands you’ve typed in your current session. This is the same list you’ll see ifyou press F7.

您将看到在当前会话中键入的命令。 如果您按F7,则将看到相同的列表。

如何复制上一个命令 (How to Copy Your Previous Command)

The previous command you typed is known as the “template”. There are a variety of shortcuts for quickly copying part of the previous command you ran.

您键入的上一个命令称为“模板”。 有多种快捷方式可用于快速复制您之前运行的命令的一部分。

F1: Copy one character at a time from the the previous command you typed. Press the F1 key repeatedly to type the command you previously typed, character by character.

F1:一次复制上一个键入的字符。 重复按F1键以逐个字符键入您先前键入的命令。

F2: Copy part of the command you previously typed. You’ll be prompted to enter a character. The system will search forward in the previous command you typed and automatically copy the text up to, but not including, that character. For example, if the last command you ran was “ping ”, you could press “F2”, type “o”, press “Enter”, and “ping g” would appear at the prompt.

F2:复制您先前键入的命令的一部分。 系统将提示您输入一个字符。 系统将在您键入的上一个命令中向前搜索,并自动将文本复制到(但不包括)该字符。 例如,如果您最后运行的命令是“ ping ”,则可以按“ F2”,键入“ o”,按“ Enter”,然后在提示符处显示“ ping g”。

F3: Copy part of the command you previously typed. The system will start from the current character position and automatically copy the remainder of the text from that position on the previous line. For example, let’s say the last command you typed was “ping -4 ”. You could type “ping -6”, press “F3″, and the system would automatically fill in ” ”, making the current line “ping -6 ”.

F3:复制您先前键入的命令的一部分。 系统将从当前字符位置开始,并自动从上一行的该位置复制其余文本。 例如,假设您输入的最后一个命令是“ ping -4 ”。 您可以输入“ ping -6”,按“ F3”,系统会自动填写“ ”,使当前行变为“ ping -6 ”。

如何清除命令历史记录 (How to Clear the Command History)

Unlike Linux’s bash shell, the Command Prompt doesn’t remember commands between sessions. To erase the historyof any commands you typed, just close the Command Prompt window.

与Linux的bash shell不同,命令提示符不会记住会话之间的命令。 要清除您键入的任何命令的历史记录,只需关闭“命令提示符”窗口。

You can tell the Command Prompt to not remember any commands you’ve typed in the current session by setting the history size to 0 with thedoskeycommand:

通过使用doskey命令将历史记录大小设置为0,可以告诉命令提示符不记得您在当前会话中键入的任何命令:

doskey /listsize=0

You won’t be able to use the arrow keys, F7 key, ordoskey /historycommand to see any commands you’ve typed after setting the list size to 0. This change also only takes effect for the current Command Prompt window, so the Command Prompt window will remember history as normal the next time you close and reopen it.

将列表大小设置为0后,您将无法使用箭头键,F7键或doskey /history命令查看您键入的任何命令。此更改也仅对当前的“命令提示符”窗口生效。 “命令提示符”窗口将在您下次关闭并重新打开它时恢复正常的历史记录。

You can use thecls(clear screen)command to clear your Command Prompt window, erasing all history of the commands you typed without closing the window:

您可以使用cls(清除屏幕)命令清除“命令提示符”窗口,在不关闭窗口的情况下清除您键入的命令的所有历史记录:

cls

如何保存命令历史记录 (How to Save Your Command History)

If you ever need to save a history of the commands you typed in a Command Prompt window, you can do it by running thedoskey /historycommand and routing its output to a text file. (You could also just run thedoskey /historycommand and copy/pastetext to another application, of course.)

如果您需要保存在“命令提示符”窗口中键入的命令的历史记录,则可以通过运行doskey /history命令并将其输出路由到文本文件来进行保存。 (当然,您也可以只运行doskey /history命令并将文本复制/粘贴到另一个应用程序。)

For example, the following command will save a copy of your current Command Prompt window’s command history to the C:\Users\name\Desktop\commands.txt file on your system.

例如,以下命令会将当前“命令提示符”窗口的命令历史记录的副本保存到系统上的C:\ Users \ name \ Desktop \ commands.txt文件中。

doskey /history > C:\Users\name\Desktop\commands.txt

The>character redirects the output of the command to the file you specify.

>字符会将命令的输出重定向到您指定的文件。

Open the file in a text editor to view the history of commands typed in that Command Prompt session.

在文本编辑器中打开文件,以查看在该命令提示符会话中键入的命令的历史记录。

These are just some of the useful keyboard shortcuts available in the Command Prompt, so check out our list for even more.

这些只是命令提示符中可用的一些有用的键盘快捷键,因此请查看我们的列表以获取更多信息 。

翻译自: /298163/how-to-use-your-command-history-in-the-windows-command-prompt/

windows命令提示符

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。