[rps-include post=6835]
[rps-include post = 6835]
Bash shell runs in terminals like gnome-terminal, konsole, getty, etc. To make things make easy bash provides some shortcuts and pragmatic operations. Here we will look details about them.
Bash shell运行在gnome-terminal,konsole,getty等终端中。为了使事情变得简单,bash提供了一些快捷方式和实用的操作。 在这里,我们将详细介绍它们。
历史 (History)
Busy system administrators writes a lot of bash commands. They have no time to write notes about the commands. But bash have a history to assist. Bash history holds commands written before. This is very helpful when you write long and rarely used command and needed right now.
繁忙的系统管理员编写了很多bash命令。 他们没有时间编写有关命令的注释。 但是bash有帮助的历史。 Bash历史记录包含之前编写的命令。 当您编写长时间且很少使用且现在需要使用的命令时,这非常有用。
上市历史 (Listing History)
$ history
1 npm run
2 cd ..
3 ls
4 npm run
5 cd react-15.3.0/
I have cut the history is long as by default 1000 line. As you see bash lists all command we have issued.
我已将历史记录默认为1000行。 如您所见,bash列出了我们发出的所有命令。
运行命令 (Rerunning command)
There is easy way to rerun previously issued command. As we see that history numbers commands. We will use these numbers to specify command like below.
有一种简单的方法可以重新运行先前发出的命令。 如我们所见,历史编号命令。 我们将使用这些数字来指定如下所示的命令。
$ !3
ls
Desktop Documents Downloads workspace
We use !3 to rerun number 3 history command. As we see that rerunning command echoes issued command which is ls
我们使用!3重新运行3号历史记录命令。 如我们所见,重新运行的命令会回显发出的命令ls
搜索历史 (Searching History)
History provides a lot of commands. And finding a specific command in list may become hard. There is easy way to filter commands.
历史记录提供了许多命令。 在列表中查找特定命令可能会变得很困难。 有一种简单的方法来过滤命令。
$ history | grep ls
3 ls
6 ls
57 ls
We get help from grep command. It filters commands that provides ls and list them.
我们从grep命令获得帮助。 它过滤提供ls的命令并列出它们。
清算记录 (Clearing History)
Some times we need to clear things we have done. For example if we provided a command with clear text password we may want to clear these commands.
有时我们需要清除已经完成的事情。 例如,如果我们为命令提供了明文密码,则可能需要清除这些命令。
$ history -c
$ history
1 history
获取历史记录大小 (Getting History Size)
History is very helpful but if we are hardworking system administrator the size of the is may become small for us. By default history size is 1000 which means the last 1000 commands will be hold.
历史记录非常有帮助,但是如果我们是一位努力的系统管理员,那么对于我们来说,这可能会变得很小。 默认情况下,历史记录大小为1000,这意味着将保留最后1000个命令。
$ echo $HISTSIZE
1000
History size is hold as bash environment variable. By changing HISTSIZE
environment variable the size may increased.
历史记录大小作为bash环境变量保存。 通过改变 HISTSIZE
环境变量的大小可能会增加。
设置历史记录大小(Setting History Size)
History is very helpful but if we are hardworking system administrator the size of the is may become small for us. By default history size is 1000 which means the last 1000 commands will be hold.
历史记录非常有帮助,但是如果我们是一位努力的系统管理员,那么对于我们来说,这可能会变得很小。 默认情况下,历史记录大小为1000,这意味着将保留最后1000个命令。
$ HISTSIZE=2000
$ echo $HISTSIZE
2000
History size is hold as a bash environment variable. By changing HISTSIZE
environment variable the size may increase.
历史记录大小作为bash环境变量保存。 通过改变 HISTSIZE
环境变量的大小可能会增加。
[rps-include post=6835]
[rps-include post = 6835]