当前位置: 首页 > news >正文

Linux shell编程学习笔记38:history命令

目录

  1. 0 前言
    1. 1  history命令的功能、格式和退出状态
    2. 1.1 history命令的功能
    3. 1.2 history命令的格式
    4. 1.3退出状态
    5. 2 命令应用实例
    6. 2.1 history:显示命令历史列表
    7. 2.2 history -a:将当前会话的命令行历史追加到历史文件~/.bash_history中
    8. 2.3 history -c:删除所有条目从而清空历史列表
    9. 2.4 history -d 偏移量:从指定位置删除历史列表内容
    10. 2.5 history 正整数:显示指定数量的历史命令纪录
    11. 2.6 history -r:读取历史文件并将内容追加到历史列表中
    12. 2.7 history -s 命令 :将 指定命令 追加到历史列表
    13. 2.8 history -w [文件]:将当前历史写入到历史文件中,并追加到历史列表中
      1. 2.8.1  将当前历史写入到默认历史文件中
      2. 2.8.2  将当前历史写入到指定文件中
    14. 2.9 !:重复执行命令
      1. 2.9.1 !! 或 !-1:重复执行上一条命令
      2. 2.9.2 !命令历史列表列号 :重复执行历史列表中指定行的命令
      3. 2.9.3 !字符串 :重复执行历史列表中以指定字符串开头的命令
    15. 2.10 其它使用技巧
      1. 2.10.1  重新执行或查看命令历史中的命令
      2. 2.10.2 使用(reverse-i-search)模式
      3. 2.10.3 使用命令历史记录中的参数
  2. 三、与history命令相关的环境变量

0 前言

使用DOS的朋友,都知道可以在命令行提示符中使用上下光标键来浏览最近执行过的命令,这是基于DOS提供的DosKey命令。

而在Unix和Linux的shell中,我们同样可以使用上下光标键来浏览最近执行过的命令历史纪录(history),这是因为有history命令。

bash可以保存的过去曾经执行过的命令。当某个用户登录到shell中,会读取该用户家目录中的~/.bash_history文件,并将历史命令列表保存到内存中。当用户退出当前shell时,会将内存中的历史命令列表覆盖至~/.bash_history文件。

 1  history命令的功能、格式和退出状态

我们可以使用 help history命令查看 history命令的帮助信息。

purpleEndurer @ bash ~ $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.
purpleEndurer @ bash ~ $

1.1 history命令的功能

history命令是一个内部命令,可以显示或操纵命令历史列表。

purpleEndurer @ bash ~ $type history
history is a shell builtin
purpleEndurer @ bash ~ $

1.2 history命令的格式

history [-c] [-d 偏移量] [历史记录数]

history -anrw [文件名]

history -ps 参数 [参数...]

选项功能备注
-a将当前会话的命令行历史追加到历史文件~/.bash_history中append
-c删除所有条目从而清空历史列表内容。clear
-d 偏移量 从指定位置删除历史列表内容。delete
历史记录数显示指定数量的历史命令纪录,应为正整数number
-n从历史文件中读取所有未被读取的行not
-p 参数对每一个指定参数展开历史并显示结果而不存储到历史列表中perform
-r读取历史文件并将内容追加到历史列表中read
-s 命令以单条记录将 指定命令 追加到历史列表中。如果指定了 文件名,则它将被作为历史文件。否则如果 $HISTFILE 变量有值的话使用之,不然使用 ~/.bash_history 文件。如果 $HISTTIMEFORMAT 变量被设定并且不为空,它的值会被用于 strftime(3) 的格式字符串来打印与每一个显示的历史条目想关联的时间戳,否则不打印时间戳。single
-w [文件]将当前历史写入到历史文件中,并追加到历史列表中write

1.3退出状态

返回成功,除非使用了无效的选项或者发生错误。


2 命令应用实例

2.1 history:显示命令历史列表

prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  history
prupleEndurer @ bash ~ $ 

 

 2.2 history -a:将当前会话的命令行历史追加到历史文件~/.bash_history中

prupleEndurer @ bash ~ $ cat ~/.bash_history
PS1="prupleEndurer @ bash \w $ "
history -2
echo $?
history
history -r
history
history
history -a
prupleEndurer @ bash ~ $ history -a
prupleEndurer @ bash ~ $ cat ~/.bash_history
PS1="prupleEndurer @ bash \w $ "
history -2
echo $?
history
history -r
history
history
history -a
history -n
ls ~/.bash_history
cat ~/.bash_history
cat ~/.bash_history -a
cls
clear
cat ~/.bash_history -a
cls
clear
cat ~/.bash_history
history -a
prupleEndurer @ bash ~ $ 

我们先执行cat ~/.bash_history 命令查看文件~/.bash_history的内容

然后执行history -a 命令将当前会话的命令行历史追加到历史文件~/.bash_history中

接着再次执行cat ~/.bash_history 命令查看文件~/.bash_history的内容

可以看到文件~/.bash_history中确实增加了下面这些命令行:

history -n
ls ~/.bash_history
cat ~/.bash_history
cat ~/.bash_history -a
cls
clear
cat ~/.bash_history -a
cls
clear
cat ~/.bash_history
history -a

2.3 history -c:删除所有条目从而清空历史列表

prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  history 0
    3  echo $?
    4  history
prupleEndurer @ bash ~ $ history -c
prupleEndurer @ bash ~ $ history
    1  history
prupleEndurer @ bash ~ $ 

我们先执行history 命令查看当前命令历史列表,内容如下:

    1  PS1="prupleEndurer @ bash \w $ "2  history 03  echo $?4  history

然后执行history -c 命令将当前会话的命令行历史列表清空

接着再次执行history 命令查看当前命令历史列表,这时历史列表只有我们这次所输入的的命令:

    1  history

之前的命令历史列表都被清空了。

2.4 history -d 偏移量:从指定位置删除历史列表内容

prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  history
    3  history 0
    4  echo $?
    5  history 3
    6  history
prupleEndurer @ bash ~ $ history -d 2
prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  history 0
    3  echo $?
    4  history 3
    5  history
    6  history -d 2
    7  history
prupleEndurer @ bash ~ $ 

我们先执行history 命令查看当前命令历史列表,内容如下:

    1  PS1="prupleEndurer @ bash \w $ "2  history3  history 04  echo $?5  history 36  history

然后执行history -d 2 命令将第2行命令删除

接着再次执行history 命令查看当前命令历史列表,内容如下:

    1  PS1="prupleEndurer @ bash \w $ "2  history 03  echo $?4  history 35  history6  history -d 27  history

可以看到命令历史列表中之前的第2条纪录:

    2  history

被删除了。 

如果我指定的偏移量是负数,例如-2,命令将出错,退出状态码为1:

prupleEndurer @ bash ~ $ history -d -2
bash: history: -2: history position out of range
prupleEndurer @ bash ~ $ echo $?
1
prupleEndurer @ bash ~ $ 

2.5 history 正整数:显示指定数量的历史命令纪录

 prupleEndurer @ bash ~/Code $ history
    1  history
prupleEndurer @ bash ~/Code $ history 1
    2  history 1
prupleEndurer @ bash ~/Code $ history 0
prupleEndurer @ bash ~/Code $ history 2
    3  history 0
    4  history 2
prupleEndurer @ bash ~/Code $ history
    1  history
    2  history 1
    3  history 0
    4  history 2
    5  history
prupleEndurer @ bash ~/Code $ 

如果我们指定的是负数,将提示出错,命令退出值为2。

prupleEndurer @ bash ~ $ history -2
bash: history: -2: invalid option
history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]prupleEndurer @ bash ~ $ echo $?
2

2.6 history -r:读取历史文件并将内容追加到历史列表中

prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  cat ~/.bash_history
    3  set | grep  $HISTFILE
    4  cat /home/csdn/.bash_history
    5  history -w
    6  cat /home/csdn/.bash_history
    7  history -w c.log
    8  cat c.log
    9  history
prupleEndurer @ bash ~ $ history -r
prupleEndurer @ bash ~ $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  cat ~/.bash_history
    3  set | grep  $HISTFILE
    4  cat /home/csdn/.bash_history
    5  history -w
    6  cat /home/csdn/.bash_history
    7  history -w c.log
    8  cat c.log
    9  history
   10  history -r
   11  PS1="prupleEndurer @ bash \w $ "
   12  cat ~/.bash_history
   13  set | grep  $HISTFILE
   14  cat /home/csdn/.bash_history
   15  history -w
   16  history
prupleEndurer @ bash ~ $ cat /home/csdn/.bash_history
PS1="prupleEndurer @ bash \w $ "
cat ~/.bash_history
set | grep  $HISTFILE
cat /home/csdn/.bash_history
history -w
prupleEndurer @ bash ~ $ 

我们先执行history 命令查看当前命令历史列表共有9条,内容如下:

    1  PS1="prupleEndurer @ bash \w $ "2  cat ~/.bash_history3  set | grep  $HISTFILE4  cat /home/csdn/.bash_history5  history -w6  cat /home/csdn/.bash_history7  history -w c.log8  cat c.log9  history

然后执行history -r 命令读取历史文件并将内容追加到历史列表中

接着再次执行history 命令查看当前命令历史列表,共有16条,内容如下:

    1  PS1="prupleEndurer @ bash \w $ "2  cat ~/.bash_history3  set | grep  $HISTFILE4  cat /home/csdn/.bash_history5  history -w6  cat /home/csdn/.bash_history7  history -w c.log8  cat c.log9  history10  history -r11  PS1="prupleEndurer @ bash \w $ "12  cat ~/.bash_history13  set | grep  $HISTFILE14  cat /home/csdn/.bash_history15  history -w16  history

我们用命令 cat /home/csdn/.bash_history 查看历史文件的内容:

PS1="prupleEndurer @ bash \w $ "
cat ~/.bash_history
set | grep  $HISTFILE
cat /home/csdn/.bash_history
history -w

可以看到,当前命令历史列表中的第10条-15条记录是从历史文件添加进来的。

2.7 history -s 命令 :将 指定命令 追加到历史列表

prupleEndurer @ bash ~/Code $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  ls
    3  cd Code
    4  pwd
    5  history
    6  pwd
    7  pwd
    8  pwd
    9  set | grep hist
   10  set | grep HIST
   11  export | grep HIST
   12  export
   13  history
prupleEndurer @ bash ~/Code $ history -s abcd
prupleEndurer @ bash ~/Code $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  ls
    3  cd Code
    4  pwd
    5  history
    6  pwd
    7  pwd
    8  pwd
    9  set | grep hist
   10  set | grep HIST
   11  export | grep HIST
   12  export
   13  history
   14  abcd
   15  history
prupleEndurer @ bash ~/Code $

在上面的实例中, 我们执行命令 history -s abcd 将  abcd 加入到命令历史列表中。

2.8 history -w [文件]:将当前历史写入到历史文件中,并追加到历史列表中

2.8.1  将当前历史写入到默认历史文件中

系统默认历史文件说明符由环境变量 HISTFILE 指定。

prupleEndurer @ bash ~ $ set | grep  $HISTFILE
HISTFILE=/home/csdn/.bash_history
_=/home/csdn/.bash_history
prupleEndurer @ bash ~ $ cat /home/csdn/.bash_history
cat: /home/csdn/.bash_history: No such file or directory
prupleEndurer @ bash ~ $ history -w
prupleEndurer @ bash ~ $ cat /home/csdn/.bash_history
PS1="prupleEndurer @ bash \w $ "
cat ~/.bash_history
set | grep  $HISTFILE
cat /home/csdn/.bash_history
history -w
prupleEndurer @ bash ~ $ 

我们先执行 set | grep  $HISTFILE 命令 查询环境变量 HISTFILE 的值为:/home/csdn/.bash_history。

然后我们执行  cat /home/csdn/.bash_history 命令查看 /home/csdn/.bash_history 的内容,结果这个文件不存在。

接着我们执行 history -w  命令将命令行历史记录 保存到 /home/csdn/.bash_history。

最后我们再次执行 cat /home/csdn/.bash_history 命令查看 /home/csdn/.bash_history 的内容,这次文件不仅存在,而且文件内容就是我们之前输入的命令。

2.8.2  将当前历史写入到指定文件中

我们将 命令行历史记录 保存到 到当前目录下的文件 c.log中。

prupleEndurer @ bash ~ $ history -w c.log
prupleEndurer @ bash ~ $ cat c.log
PS1="prupleEndurer @ bash \w $ "
cat ~/.bash_history
set | grep  $HISTFILE
cat /home/csdn/.bash_history
history -w
cat /home/csdn/.bash_history
history -w c.log
prupleEndurer @ bash ~ $ 

  

首先,我们执行命令  history -w c.log   将 命令行历史记录 保存到 到当前目录下的文件 c.log中。

然后,我们执行命令  cat c.log   查看文件 c.log 的内容。

2.9 !:重复执行命令

2.9.1 !! 或 !-1:重复执行上一条命令

prupleEndurer @ bash ~/Code $ pwd
/home/csdn/Code
prupleEndurer @ bash ~/Code $ !!
pwd
/home/csdn/Code
prupleEndurer @ bash ~/Code $ !-1
pwd
/home/csdn/Code
prupleEndurer @ bash ~/Code $ 

 

我们执行命令!! 或 !-1 ,均会重复执行上一条命令pwd

除了以上两种方法,还有两种方法 :

  • 使用方向键↑选中命令,按↑↓调整,并回车执行
  • 按Ctrl + p,调出命令,并回车执行

 2.9.2 !命令历史列表列号 :重复执行历史列表中指定行的命令

prupleEndurer @ bash ~ $ ls
Code
prupleEndurer @ bash ~ $ ls Code
prupleEndurer @ bash ~ $ cd Code
prupleEndurer @ bash ~/Code $ ls
prupleEndurer @ bash ~/Code $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  ls
    3  ls Code
    4  cd Code
    5  ls
    6  history
prupleEndurer @ bash ~/Code $ !2
ls
prupleEndurer @ bash ~/Code $ ! 2
bash: 2: command not found

在上面的实例中,命令 !2 会执行命令历史列表中的 第2条命令 ls

由于 当前目录 下没有内容,所以ls命令没有显示。

如果 我们输入的命令是 ! 2,就会报错。

注意:

  • ! 与 命令历史列表列号 之间不能有空格。
  • 命令历史列表列号如果为正整数,则从头往下数;如果为负整数,则从下往上倒数,例如!-1执行的就是命令列表中最后一条命令

如果我们指定的命令历史列表列号 不在 命令历史列表实际列数中,会怎么样呢?

prupleEndurer @ bash ~/Code $ !0
bash: !0: event not found
prupleEndurer @ bash ~/Code $ echo $?
0
prupleEndurer @ bash ~/Code $ !100
bash: !100: event not found
prupleEndurer @ bash ~/Code $ echo $?
0
prupleEndurer @ bash ~/Code $ 

我们执行命令 !0 和 !100,系统都会提示:event not found

而命令返回值均为0。

 2.9.3 !字符串 :重复执行历史列表中以指定字符串开头的命令

prupleEndurer @ bash ~/Code $ history
    1  PS1="prupleEndurer @ bash \w $ "
    2  ls
    3  ls Code
    4  cd Code
    5  ls
    6  history
    7  ls
    8  ! 2
    9  cd Code
   10  ehco $?
   11  echo $?
   12  echo $?
   13  echo $?
   14  echo $?
   15  echo $?
   16  history
prupleEndurer @ bash ~/Code $ !cd
cd Code
bash: cd: Code: No such file or directory
prupleEndurer @ bash ~/Code $ ! cd
prupleEndurer @ bash ~ $ !ls
ls
Code
prupleEndurer @ bash ~ $ !ls Cod
ls Cod
ls: cannot access Cod: No such file or directory
prupleEndurer @ bash ~ $ echo $?
2
prupleEndurer @ bash ~ $ 

我们行执行命令 history 查看当前命令历史列表

然后先后执行 了 !cd! cd!ls !ls Cod 命令。从执行情况看,要注意两点:

  1. ! 和 字符串 之间不能有空格
  2. 如果命令历史列表中不包括指定字符串的命令,系统会直接执行字符串,比如 !ls Cod

2.10 其它使用技巧

网上介绍的一些使用技巧,大家可以试试。

2.10.1  重新执行或查看命令历史中的命令

  • !:0 将前一条命令去除参数再执行
  • Ctrl + n显示当前历史中的下一条命令,但不执行
  • Ctrl + j执行当前命令
  • !?string 重复前一个包含string字符串的命令
  • !string:p   仅打印命令历史,而不执行
  • !$:p 打印输出!$(上一条命令的最后一个参数)的内容
  • !*:p 打印输出!*(上一条命令的所有参数)的内容
  • ^string 删除上一条命令中的第一个string
  • ^string1^string2将上一条命令中的第一个string1替换为string2
  • !:gs/string1/srting2 将上一条命令中所有的string1都替换为string2

2.10.2 使用(reverse-i-search)模式

Crtl + r:在命令历史中搜索命令

Crtl + g:从历史搜索模式退出

2.10.3 使用命令历史记录中的参数

  •  重新调用前一个命令中最后一个参数

     有3种方法:

  1. !$
  2. Esc . (点击Esc键后松开,然后点击.键)
  3. Alt+. (按住Alt键的同时点击.键),在一些终端软件中屏蔽了Alt功能键,需要开启
  • command !^      利用上一个命令的第一个参数做cmd的参数
  • command !$      利用上一个命令的最后一个参数做cmd的参数
  • command !*      利用上一个命令的全部参数做cmd的参数
  • command !:n     利用上一个命令的第n个参数做cmd的参数
  • command !n:^    调用第n条命令的第一个参数
  • command !n:$    调用第n条命令的最后一个参数
  • command !n:m    调用第n条命令的第m个参数
  • command !n:*    调用第n条命令的所有参数
  • command !srting:^   从命令历史中搜索string开头的命令,并获取它的第一个参数
  • command !srting:$   从命令历史中搜索string开头的命令,并获取它的最后一个参数
  • command !srting:n   从命令历史中搜索string开头的命令,并获取它的第n个参数
  • command !srting:*   从命令历史中搜索string开头的命令,并获取它的所有参数

三、与history命令相关的环境变量

prupleEndurer @ bash ~/Code $ set | grep HIST
HISTFILE=/home/csdn/.bash_history
HISTFILESIZE=500
HISTSIZE=500

  • HISTFILE        :指定了默认命令历史文件说明符
  • HISTFILESIZE:指定默认命令历史文件中保存命令的记录总数,即命令历史文件中最多只有HISTFILESIZE行
  • HISTSIZE       :指定了 history 命令输出的记录数,即输出命令历史文件中的最后HISTSIZE行

相关文章:

Linux shell编程学习笔记38:history命令

目录 0 前言 1 history命令的功能、格式和退出状态1.1 history命令的功能1.2 history命令的格式1.3退出状态2 命令应用实例2.1 history:显示命令历史列表2.2 history -a:将当前会话的命令行历史追加到历史文件~/.bash_history中2.3 history -c&#xf…...

elasticsearch安装教程(超详细)

1.1 创建网络(单点部署) 因为我们还需要部署 kibana 容器,因此需要让 es 和 kibana 容器互联,所有先创建一个网络: docker network create es-net 1.2.加载镜像 采用的版本为 7.12.1 的 elasticsearch;…...

arkts中@Watch监听的使用

概述 Watch用于监听状态变量的变化,当状态变量变化时,Watch的回调方法将被调用。Watch在ArkUI框架内部判断数值有无更新使用的是严格相等(),遵循严格相等规范。当在严格相等为false的情况下,就会触发Watch的…...

【Jmeter】Jmeter基础9-BeanShell介绍

3、BeanShell BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法。 3.1、Jmeter中使用的BeanShell 在Jmeter中,除了配置元件,其他类型的元件中都有BeanShell。BeanShell 是一种完全符合Java语法规范的脚本语言,并且又拥…...

详解数组的轮转

𝙉𝙞𝙘𝙚!!👏🏻‧✧̣̥̇‧✦👏🏻‧✧̣̥̇‧✦ 👏🏻‧✧̣̥̇:Solitary-walk ⸝⋆ ━━━┓ - 个性标签 - :来于“云”的“羽球人”。…...

html 表格 笔记

<!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>第二个页面</title><meta name"language" content"cn"> </head> <body><h2 sytle"width:500px;…...

计算机网络【HTTP 面试题】

HTTP的请求报文结构和响应报文结构 HTTP请求报文主要由请求行、请求头、空行、请求正文&#xff08;Get请求没有请求正文&#xff09;4部分组成。 1、请求行 由三部分组成&#xff0c;分别为&#xff1a;请求方法、URL以及协议版本&#xff0c;之间由空格分隔&#xff1b;请…...

linux基于用户身份对资源访问进行控制的解析及过程

linux中用户分为三类 1.超级用户&#xff08;root&#xff09; 拥有至高无上的权限 2.普通用户 人为创建、权限小&#xff0c;权限受到控制 3.程序用户 运行程序的用户&#xff0c;不是给人使用的&#xff0c;给程序使用的&#xff0c;一般不给登录&#xff01; 组账…...

手动创建idea SpringBoot 项目

步骤一&#xff1a; 步骤二&#xff1a; 选择Spring initializer -> Project SDK 选择自己的JDK版本 ->Next 步骤三&#xff1a; Maven POM ->Next 步骤四&#xff1a; 根据JDK版本选择Spring Boot版本 11版本及以上JDK建议选用3.2版本&#xff0c;JDK为11版本…...

【Go语言入门:Go语言的数据结构】

文章目录 3.Go语言的数据结构&#xff1a;3.1. 指针3.2. struct&#xff08;结构体&#xff09;3.3. Map(映射,哈希&#xff09; 3.Go语言的数据结构&#xff1a; 简介&#xff1a; 在Go语言中&#xff0c;数据结构体可以分为四种类型&#xff1a;基础类型、聚合类型、引用类型…...

QT designer的ui文件转py文件之后,实现pycharm中运行以方便修改逻辑,即添加实时模板框架

为PyCharm中的实时模板&#xff0c;你需要遵循以下步骤&#xff1a; 打开PyCharm的设置: 选择 File > Settings&#xff08;在macOS上是 PyCharm > Preferences&#xff09;。 导航到实时模板: 在设置中找到 Editor > Live Templates。 添加新的模板组 (可选): 为了…...

什么是负载均衡?

负载均衡是指在计算机网络领域中&#xff0c;将客户端请求分配到多台服务器上以实现带宽资源共享、优化资源利用率和提高系统性能的技术。负载均衡可以帮助小云有效解决单个服务器容量不足或性能瓶颈的问题&#xff0c;小云通过平衡流量负载&#xff0c;使得多台服务器能够共同…...

Python和Java的优缺点

Python的优点&#xff1a; 简单易学&#xff1a;Python的语法简洁清晰&#xff0c;易于学习和理解。丰富的库和框架&#xff1a;Python拥有庞大的标准库和活跃的开源社区&#xff0c;可以快速使用各种功能强大的库和框架&#xff0c;比如NumPy、Pandas、Django等。可读性强&am…...

AES - 在tiny-AES-c基础上封装了2个应用函数(加密/解密)

文章目录 AES - 在tiny-AES-c基础上封装了2个应用函数(加密/解密)概述增加2个封装函数的AES库aes.haes.c在官方测试程序上改的测试程序(用来测试这2个封装函数)END AES - 在tiny-AES-c基础上封装了2个应用函数(加密/解密) 概述 在github山有个星数很高的AES的C库 tiny-AES-c …...

51和32单片机读取FSR薄膜压力传感器压力变化

文章目录 简介线性电压转换模块51单片机读取DO接线方式51代码实验效果 32单片机读取AO接线方式32代码实验效果 总结 简介 FSR薄膜压力传感器是可以将压力变化转换为电阻变化的一种传感器&#xff0c;单片机可以读取然后作为粗略测量压力&#xff08;仅提供压力变化&#xff0c;…...

【maven】pom.xml 文件详解

有关 maven 其他配置讲解参考 maven 配置文件 setting.xml 详解 pom.xml 文件是 Maven 项目的核心配置文件&#xff0c;其中包含了项目的元数据、构建配置、依赖管理等信息。以下是一个 pom.xml 文件的主要部分&#xff1a; <?xml version"1.0" encoding"U…...

SpringMVC源码解析——DispatcherServlet初始化

在Spring中&#xff0c;ContextLoaderListener只是辅助功能&#xff0c;用于创建WebApplicationContext类型的实例&#xff0c;而真正的逻辑实现其实是在DispatcherServlet中进行的&#xff0c;DispatcherServlet是实现Servlet接口的实现类。Servlet是一个JAVA编写的程序&#…...

搞定Apache Superset

踩雷了无数次终于解决了Superset的一系列问题 现在是北京时间2023年12月27日&#xff0c;亲测有效。 Superset概述 Apache Superset是一个现代的数据探索和可视化平台。它功能强大且十分易用&#xff0c;可对接各种数据源&#xff0c;包括很多现代的大数据分析引擎&#xff…...

【每日试题】java面试之ssm框架

以下是20道常见的SSM&#xff08;SpringSpring MVCMyBatis&#xff09;面试题目和答案&#xff1a; 什么是SSM框架&#xff1f; SSM是指SpringSpring MVCMyBatis的组合&#xff0c;它是Java Web开发中常用的轻量级框架集合。 介绍一下SSM框架各个组件的作用&#xff1f; Sprin…...

Flutter 疑难杂症集合

一. Flutter集成uni小程序sdk 1. 手机连接电脑测试打开uni小程序没问题&#xff0c;打包成apk后debug编译下的apk也没问题&#xff0c;但就是release编译的apk包打不开小程序。 报错情景&#xff1a;点击后页面会闪现一下黑色的背景&#xff0c;然后又跳转回了点击之前的页面。…...

PHP序列化总结1--序列化和反序列化的基础知识

序列化和反序列化的作用 1.序列化&#xff1a;将对象转化成数组或者字符串的形式 2.反序列化&#xff1a;将数组或字符串的形式转化为对象 为什么要进行序列化 这种数据形式中间会有很多空格&#xff0c;不同人有不同的书写情况&#xff0c;可能还会出现换行的情况 为此为了…...

【Linux】 last 命令使用

last 命令 用于检索和展示系统中用户的登录信息。它从/var/log/wtmp文件中读取记录&#xff0c;并将登录信息按时间顺序列出。 著者 Miquel van Smoorenburg 语法 last [-R] [-num] [ -n num ] [-adiox] [ -f file ] [name...] [tty...]last 命令 -Linux手册页 选项及作用…...

Git 分布式版本控制系统(序章1)

第一章 Git 分布式版本控制系统 为什么学Git? 某些企业面试需要掌握Git&#xff0c;同时&#xff0c;也方便管理自己的Qt项目。 一、Git 客户端下载&#xff08;Windows&#xff09; 下载地址 https://gitee.com/all-about-git#git-%E5%A4%A7%E5%85%A8 二、Git 的特点 分支…...

给WordPress网站添加返回顶部按钮

给WordPress网站底部添加一个按钮&#xff0c;点它就可以现实快速返回到顶部。有两种方法可以现实&#xff0c;一种是通过安装相关插件来实现。另外一种方式就是以纯属代码的方式来实现。 给WordPress网站底部添加一个按钮&#xff0c;点它就可以现实快速返回到顶部。有两种方…...

App Inventor 2 接入短信服务,实现短信验证码功能

发送短信验证码功能一般都是基于短信平台提供的sdk进行调用&#xff0c;这里是基于阿里云短信平台进行的开发&#xff0c;阿里云短信平台接入步骤请点此参考。 App Inventor 2拓展提供的函数如下&#xff1a; 主要提供2个函数&#xff0c;生成随机位数的数字随机码 和 发送短信…...

Linux环境grep搜索方法记录

1 grep grep 命令&#xff0c;用来搜索字符串所在位置&#xff0c;可以具体到不同文件&#xff0c;不同行&#xff1b; 在Linux 下&#xff0c;查看命令释义如下 zhaocubuntu2004:~$ grep --help Usage: grep [OPTION]... PATTERNS [FILE]... Search for PATTERNS in each FI…...

C语言-破解密码

题目描述 密码是我们生活中非常重要的东东&#xff0c;我们的那么一点不能说的秘密就全靠它了。哇哈哈. 接下来渊子要在密码之上再加一套密码&#xff0c;虽然简单但也安全。 假设老王原来一个BBS上的密码为zvbo941987,为了方便记忆&#xff0c;他通过一种算法把这个密码变换…...

ffmpeg 解码文件时的时间戳问题

实时流和普通文件 1 实时流 实时流编码时&#xff0c;我们一般不进行b帧编码&#xff0c;但是文件存储时为了减小大小&#xff0c;会增加b帧&#xff0c;实时流只带了I&#xff0c;P帧&#xff0c;那就会好很多 2 普通文件 很多文件带了b帧&#xff0c;所以要使用解码时间去同…...

Java企业电子招投标系统源代码,支持二次开发,采用Spring cloud框架

在数字化采购领域&#xff0c;企业需要一个高效、透明和规范的管理系统。通过采用Spring Cloud、Spring Boot2、Mybatis等先进技术&#xff0c;我们打造了全过程数字化采购管理平台。该平台具备内外协同的能力&#xff0c;通过待办消息、招标公告、中标公告和信息发布等功能模块…...

[python]基于faster whisper实时语音识别语音转文本

语音识别转文本相信很多人都用过&#xff0c;不管是手机自带&#xff0c;还是腾讯视频都附带有此功能&#xff0c;今天简单说下&#xff1a; faster whisper地址&#xff1a; https://github.com/SYSTRAN/faster-whisperhttps://link.zhihu.com/?targethttps%3A//github.com…...

2023纠结中前行? 2024继续还是放下?

喝下2023年的第一口雪碧&#xff0c;没有想像中的那么期待&#xff0c;甜水&#xff0c;放弃吧&#xff1b;还是吃些水果吧&#xff0c;不行吃块肉、喝两口酒~ 关于生活 挣扎了10几年的一颗牙“终于“掉了&#xff0c;几个月时间都在为新牙努力着&#xff1b;”进了医院就不在…...

原型链补充

1.什么是原型对象 函数的独有属性,他用prototype来表示,可以在函数的prototype上挂载一些公用的属性和方法,供实例化对象来访问。 2.__proto__属性 这个属性每一个对象都有,实例化对象就是通过这个属性,来访问原型对象上的属性和方法的。 3.三者之间的关系 1.在构造函数的原型…...

《Linux Nano命令详解:小而强大的文本编辑器》

《Linux Nano命令详解&#xff1a;小而强大的文本编辑器》 引言&#xff1a; 在Linux系统中&#xff0c;文本编辑是开发和系统管理中不可或缺的一部分。虽然有许多强大的文本编辑器可供选择&#xff0c;但Nano以其简单易用、小巧灵活而备受喜爱。本文将深入探讨Nano命令&…...

系列四、Eureka自我保护

一、Eureka自我保护 1.1、故障现象 保护模式主要用于一组客户端和Eureka Server之间存在网络分区场景下的保护。一旦进入保护模式&#xff0c;Eureka Server将会尝试保护其服务注册表中的信息&#xff0c;不再删除服务注册表中的数据&#xff0c;也就是不会注销任何微服务。如…...

C++回调函数-实操(二)

回调通常通过函数指针、函数对象&#xff08;仿函数&#xff09;、Lambda 表达式或者 std::function 来实现。 1、函数指针实现回调 这一方法实现回调比较好记&#xff0c;就记住把函数当作参数传给方法&#xff0c;在方法中调用方法。 #include <iostream>// 回调函数…...

MySQL中常用的用户授权操作

mysql 用户授权 1 &#xff09;概述 让每个应用程序&#xff0c;单独开一个mysql的用户权限所有mysql用户存储在 mysql库的user表中 2 ) 多种用户授权方式示例 show databases; use mysql;select user, authentication_string, host from mysql.user;-- 创建和删除用户 -- c…...

LabVIEW开发智能火灾自动报警系统

LabVIEW开发智能火灾自动报警系统 系统基于LabVIEW虚拟仪器开发&#xff0c;由火灾报警控制器、感温感烟探测器、手动报警器、声光报警器、ZigBee无线通讯节点以及上位机电脑等组成&#xff0c;展示了LabVIEW在智能化火灾预警与控制方面的应用。该系统通过结合二总线协议和Zig…...

Vagrant使用教程

vmware下载地址&#xff1a;https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html VirtualBox下载地址&#xff1a;https://www.virtualbox.org/wiki/Downloads Vagrant下载地址&#xff1a;https://developer.hashicorp.com/vagrant/install#…...

【Java】ThreadLocal原理与使用场景

ThreadLocal原理&#xff1a; 字段&#xff1a; //ThreadLocal对象的哈希码 private final int threadLocalHashCode nextHashCode();//生成ThreadLocal对象的哈希码时&#xff0c;需要用到该对象&#xff0c;从0开始 private static AtomicInteger nextHashCode new Atomic…...

软件测试/测试开发丨Linux进阶命令(curl、jq)

1、 curl 接口请求 curl是一个发起请求数据给服务器的工具curl支持的协议FTP、FTPS、HTTP、HTTPS、TFTP、SFTP、Gopher、SCP、Telnet、DICT、FILE、LDAP、LDAPS、IMAP、POP3、SMTP和RTSPcurl是一个非交互的工具 2、 curl 发起 get 请求 -G&#xff1a;使用get请求-d&#xf…...

模式识别与机器学习-SVM(带软间隔的支持向量机)

SVM&#xff08;带软间隔的支持向量机&#xff09; 软间隔思想的由来软间隔的引入 谨以此博客作为复习期间的记录。 软间隔思想的由来 在上一篇博客中&#xff0c;回顾了线性可分的支持向量机,但在实际情况中&#xff0c;很少有完全线性可分的情况&#xff0c;大部分线性可分…...

CentOS 7 firewalld+ipset+定时任务防御ssh暴力破解——筑梦之路

对于暴露在公网上的linux服务器&#xff0c;很容易被暴力破解登陆&#xff0c;为了增强服务器的安全性&#xff0c;因此对于ssh安全加固是很有必要的&#xff0c;这里主要介绍centos7 系统如何使用ipsetfirewalld定时任务来对ssh服务进行安全加固。 定义firewalld ipset fire…...

ElasticSearch的RestClient结合Sniffer提高可用性

一、背景 由于要安装分词器插件&#xff0c;所以需要重启ElasticSearch集群以使得新安装的插件生效 但是在重启集群的过程中&#xff0c;服务端代码却出现了大量错误&#xff0c;如下所示 java.net.ConnectException: Connection refused    at org.elasticsearch.client.R…...

【网络面试(2)】DNS原理-域名和IP地址的查询转换

从上一篇博客我们得知浏览器是如何生成了HTTP消息了&#xff0c;但是浏览器作为应用程序&#xff0c;是不具备向网络中发送请求的能力&#xff0c;而是需要委托给操作系统的内核协议栈来发送请求。在委托协议栈之前&#xff0c;浏览器还要做的一件事情就是将域名转换为IP地址。…...

【PHP】函数array_intersect、array_diff:从数组中取出、去除指定的几个键值

1.从数组中取出 &#xff1a;array_intersect 要从数组中取出指定的几个键值&#xff0c;可以使用 array_intersect_key 函数。以下是一个示例&#xff1a; $array [name > John,age > 30,email > johnexample.com,city > New York ];$keys [name, email];$resu…...

【华为机试】2023年真题B卷(python)-冠亚军排名-奖牌榜排名

一、题目 题目描述&#xff1a; 2012伦敦奥运会即将到来&#xff0c;大家都非常关注奖牌榜的情况&#xff0c;现在我们假设奖牌榜的排名规则如下. 1.首先gold medal数量多的排在前面 2.其次silver medal数量多的排在前面 3.然后bronze medal数量多的排在前面 4.若以上三个条…...

MyBatisPlus之逻辑删除

系列文章目录 提示&#xff1a;这里可以添加系列文章的所有文章的目录&#xff0c;目录需要自己手动添加 MyBatisPlus之逻辑删除 提示&#xff1a;写完文章后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 系列文章目录前言一、什么是逻辑删…...

在macOS中搭建.NET MAUI开发环境

文章目录 准备安装扩展安装 .NET安装工作负载安装 Xcode 命令行工具调试安卓应用安装 JDK安装 Android SDK 安装 Android 模拟器安装模拟器安装镜像创建虚拟机 同意许可条款创建 MAUI 项目调试 MAUI 应用切换调试目标 参考资料 准备 一台 macOS Monterey 以上的电脑安装 XCode…...

[NCTF 2022]calc

[NCTF 2022]calc 考点&#xff1a;python环境变量注入 打开题目&#xff0c;F12有hint 访问一下得到源码 app.route("/calc",methods[GET]) def calc():ip request.remote_addrnum request.values.get("num")log "echo {0} {1} {2}> ./tmp/log…...

【pandas_不重复项计数】

听说WPS没有非重复项计数的功能&#xff0c;而office需要添加到数据模型之后&#xff0c;才可以使用该功能。而用pandas&#xff0c;既可以对重复项计数&#xff0c;又可以对非重复项计数。 # 使用提醒: # 1. xbot包提供软件自动化、数据表格、Excel、日志、AI等功能 # 2. pack…...