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

做网站要自己租服务器吗/女生学市场营销好吗

做网站要自己租服务器吗,女生学市场营销好吗,微网站在哪建,typecho做网站以下内容整理于《linux命令行与shell脚本编程大全【第三版】》一书。 一、简介sed编辑器 1、sed编辑器的本质 sed是stream editor的缩写,中文意思是“流编辑器”。 sed编辑器是一个命令行编辑器,也就是可以在命令行上完成数据的处理(替换、…

以下内容整理于《linux命令行与shell脚本编程大全【第三版】》一书。

一、简介sed编辑器

1、sed编辑器的本质

sed是stream editor的缩写,中文意思是“流编辑器”。

sed编辑器是一个命令行编辑器,也就是可以在命令行上完成数据的处理(替换、删除、插入、修改、转换等操作)。

sed编辑器本质是一个Shell外部命令,因此也叫sed命令,通过该命令可以基于某些规则来编辑数据流。

2、sed编辑器的使用 

在命令行上使用sed命令的格式如下:

sed option script file

(1)file表示要处理哪个文本文件,如果没有明确指出,则默认从标准输入流获得内容。

(2)script表示编辑器命令,也就是对file进行哪些操作。

  • 这些编辑器命令可以直接写在命令行上,也可以写在一个文件中。
  • 如果编辑器命令中有空格,则必须用单引号包围起来。
  • 直接写在命令行时,如果有多条命令,则命令之间以分号隔开,此时option要写为-e。
  • 写在一个文件中时,如果有多条命令,则一行写一条命令即可,末尾不需要分号,此时option要写成-f。

(3)optiton的可选项包括-e、-f和-n。

  • -e表示在命令行上有多条编辑器命令。
  • -f表示编辑器命令写在一个文件中。
  • -n表示禁止sed编辑器输出。

(4)sed编辑器并不会修改文本文件的内容,它只会将修改后的数据发送到标准输出,原来的文本文件依然保留着原始的数据。

  • sed编辑器一次从输入(文件或者标准输入流)中获取一行的数据。
  • 根据所提供的编辑器命令script匹配数据。
  • 按照编辑器命令修改数据流中的数据。
  • 将修改后的数据输出到标准输出中。

(5)以sed编辑器命令中的文本替换命令s为例,说明上述的内容。

xjh@ubuntu:~/iot/tmp$ cat data1.txt #data1.txt文件内容
This is a test
xjh@ubuntu:~/iot/tmp$ sed 's/test/big test/' data1.txt #从文件中获取要处理的数据
This is a big test
xjh@ubuntu:~/iot/tmp$ sed -n 's/test/big test/' data1.txt #添加-n选项后没有内容输出
xjh@ubuntu:~/iot/tmp$
xjh@ubuntu:~/iot/tmp$ sed -e 's/test/big test/;s/This/It/' data1.txt #在命令行输入多条编辑命令,用分号隔开,添加-e选项
It is a big test
xjh@ubuntu:~/iot/tmp$ sed 's/test/big test/;s/This/It/' data1.txt #没有-e选项也可以?
It is a big test
xjh@ubuntu:~/iot/tmp$ sed 's/XJH/XJQ/' #这里没有给出要处理的内容,所以默认从标准输入获取,因此接下来要键入内容
XJH is very handsome #输入内容
XJQ is very handsome #显示处理后的内容
My name is XJH       #如果没有输入ctrl+d产生EOF字符,则会要求一直输入,并一直输入
My name is XJQ
xjh@ubuntu:~/iot/tmp$ cat script.sed #编辑器命令写在一个文件中,后缀.sed只是为区分shell脚本,非必需
s/XJH/XJQ/
s/handsome/beautiful/
s/boy/girl/
xjh@ubuntu:~/iot/tmp$ cat data2.txt 
XJH is very handsome
XJH is a handsome boy
xjh@ubuntu:~/iot/tmp$ sed -f script.sed data2.txt #编辑器命令写在一个文件中,需添加-f选项
XJQ is very beautiful
XJQ is a beautiful girl
xjh@ubuntu:~/iot/tmp$ cat  data2.txt  #sed编辑器不会修改文本文件的内容,原来的文本文件依然保留着原始的数据。
XJH is very handsome
XJH is a handsome boy
xjh@ubuntu:~/iot/tmp$ sed script.sed data2.txt 
sed: -e expression #1, char 10: unterminated `s' command
xjh@ubuntu:~/iot/tmp$ sed -nf script.sed data2.txt 
xjh@ubuntu:~/iot/tmp$ sed -n -f script.sed data2.txt 
xjh@ubuntu:~/iot/tmp$ 

二、sed编辑器的命令

sed编辑器定义了很多类型的命令,比如文本替换命令s、删除命令d、插入命令i、修改命令c、转换命令y、写入命令w等命令, 这些命令可以满足不同的编辑需求。

1、文本替换命令s

上面的例子是文本替换命令s的简单情形,接下来讲解其复杂一些的情形。

(1)可以将字符串分隔符修改为其他字符。

xjh@ubuntu:~/iot/tmp$ cat data1.txt 
This is a test
xjh@ubuntu:~/iot/tmp$ sed 's/test/big test/' data1.txt 
This is a big test
xjh@ubuntu:~/iot/tmp$ sed 's:test:big test:' data1.txt
This is a big test
xjh@ubuntu:~/iot/tmp$ sed 's!test!big test!' data1.txt
This is a big test
xjh@ubuntu:~/iot/tmp$

(2)可以选用替换标志来控制替换的方式。格式如下:

s/pattern/replacement/flags
  • 数字,表示替换第几处模式匹配的地方。
  • g,表示新文本将替换所有匹配的文本。
  • p,表示打印与模式匹配的行的原先内容。
  • w file,表示将替换的结果写到文件file中。
xjh@ubuntu:~/iot/tmp$ cat data3.txt
This is a test of the test script.
This is the second test of the test script.
xjh@ubuntu:~/iot/tmp$ sed 's/test/trial/' data3.txt  #默认替换每行中第一处匹配
This is a trial of the test script.
This is the second trial of the test script.
xjh@ubuntu:~/iot/tmp$ sed 's/test/trial/2' data3.txt #使用数字,指定替换每行中第几处匹配
This is a test of the trial script.
This is the second test of the trial script.
xjh@ubuntu:~/iot/tmp$ sed 's/test/trial/g' data3.txt #使用g,指定替换每行中所有的匹配
This is a trial of the trial script.
This is the second trial of the trial script.
xjh@ubuntu:~/iot/tmp$ sed 's/test/trial/p' data3.txt #使用p,表示如果匹配,则在输出替换后的内容之前,先输出原先行的内容
This is a trial of the test script.
This is a trial of the test script.
This is the second trial of the test script.
This is the second trial of the test script.
xjh@ubuntu:~/iot/tmp$ sed -n 's/test/trial/p' data3.txt #-n选项表示禁止sed输出,
This is a trial of the test script.                     #但p标志会输出修改后的行,二者结合表示输出替换后的内容
This is the second trial of the test script.
xjh@ubuntu:~/iot/tmp$ sed 's/test/trial/w test.txt' data3.txt #使用w,指定将替换后的结果输出到文件中
This is a trial of the test script.
This is the second trial of the test script.
xjh@ubuntu:~/iot/tmp$ cat test.txt 
This is a trial of the test script.
This is the second trial of the test script.
xjh@ubuntu:~/iot/tmp$ 

(3)通过行寻址,可以让编辑器命令只作用于文本文件的某些特定的行。在sed编辑器中可以用数字来表示特定的行或者行区间,或者可以用文本模式过滤出特定的行。注意,下面的例子都是以s命令为例进行说明的,但其实其他命令也适用。

【1】以数字来表示特定的行或者行区间,使用格式如下。

sed '起始行号,结束行号s/pattern/replacement/' file

如果有多条命令,则使用{ }将多条(以分号隔开,或者用次提示符的方式)的命令包围起来。

注意,sed编辑器将文本流中的第一行编号为1,文本流最后一行用$来表示。 

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
XJH is a boy.
XJH is a boy.
XJH is a boy.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$ sed '2s/boy/girl/' data4.txt #替换第2行
XJH is a boy.
XJH is a girl.
XJH is a boy.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$ sed '2 s/boy/girl/' data4.txt #有空格也行
XJH is a boy.
XJH is a girl.
XJH is a boy.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$ sed '2,3s/boy/girl/' data4.txt #标准例子
XJH is a boy.
XJH is a girl.
XJH is a girl.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$ sed '2,$s/boy/girl/' data4.txt #符号$表示文本最后一行
XJH is a boy.
XJH is a girl.
XJH is a girl.
XJH is a girl.
xjh@ubuntu:~/iot/tmp$ sed '2,3{s/boy/girl/;s/XJH/XJQ/}' data4.txt #多条命令的写法1
XJH is a boy.
XJQ is a girl.
XJQ is a girl.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$ sed '2,3{s/boy/girl/ 
> s/XJH/XJQ/
> }' data4.txt
XJH is a boy.                                  #多条命令的写法2
XJQ is a girl.
XJQ is a girl.
XJH is a boy.
xjh@ubuntu:~/iot/tmp$

 【2】用文本模式过滤出特定的行,使用格式如下。

sed '/pattern/s/pattern_s/replacement/' file

如果有多条命令,则使用{ }将多条(以分号隔开,或者用次提示符的方式)的命令包围起来。  

xjh@ubuntu:~/iot/tmp$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
xjh@ubuntu:~/iot/tmp$ sed -n '/root/s/bash/sh/p' /etc/passwd #添加-n选项与替换标志p,只打印替换后的行内容
root:x:0:0:root:/root:/bin/sh
xjh@ubuntu:~/iot/tmp$ sed '/root/s/bash/sh/' /etc/passwd #否则会打印全部内容
root:x:0:0:root:/root:/bin/sh
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
[……省略部分内容……]
xjh@ubuntu:~/iot/tmp$ sed '/root/{s/bash/sh/;s/bin/usrbin/}' /etc/passwd
root:x:0:0:root:/root:/usrbin/sh
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
[……省略部分内容……]
xjh@ubuntu:~/iot/tmp$ sed -n '/root/{s/bash/sh/p;s/bin/usrbin/}' /etc/passwd
root:x:0:0:root:/root:/bin/sh
xjh@ubuntu:~/iot/tmp$ sed -n '/root/{s/bash/sh/;s/bin/usrbin/p}' /etc/passwd
root:x:0:0:root:/root:/usrbin/sh
xjh@ubuntu:~/iot/tmp$ sed -n '/root/{s/bash/sh/p;s/bin/usrbin/p}' /etc/passwd
root:x:0:0:root:/root:/bin/sh
root:x:0:0:root:/root:/usrbin/sh
xjh@ubuntu:~/iot/tmp$

2、删除特定行命令d

如果要删除文本流中的特定行,可以使用删除命令d。

可以通过上面提到的两种行寻址方式,来匹配要删除的某些行。

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '3d' data4.txt 
This is line number 1.
This is line number 2.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '2,3d' data4.txt 
This is line number 1.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '3,$d' data4.txt 
This is line number 1.
This is line number 2.
xjh@ubuntu:~/iot/tmp$ sed '/number 3/d' data4.txt 
This is line number 1.
This is line number 2.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '/number 2/,/number 4/d' data4.txt 
This is line number 1.
xjh@ubuntu:~/iot/tmp$

3、插入命令i、附加命令a

插入命令i(insert的首字母),会在指定行之前增加一个新行。

附加命令a(append的首字母),会在指定行之后增加一个新行。

这两个命令的使用格式如下,其中command为i或者a,file表示要往哪个文件中插入或者附加(如果缺省,则默认插入或者附加到输入流中),new_line表示要添加的内容,而address表示往文件中的哪一行插入或者附加(可以通过之前说的两种行寻址方式来确定这个地址)。

sed '[address]command\new_line' file
xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ echo "Test line 2" | sed 'i\Test line 1'
Test line 1
Test line 2
xjh@ubuntu:~/iot/tmp$ echo "Test line 2" | sed 'a\Test line 1'
Test line 2
Test line 1
xjh@ubuntu:~/iot/tmp$ sed 'i\Test line 1'#因为缺省file,则默认从输入流获取内容
Test line 2 #因此要输入一行内容,并按回车
Test line 1 #接下来的两行是结果的显示。注意,如果不按ctrl+d产生EOF符号,会提示一直输入
Test line 2
xjh@ubuntu:~/iot/tmp$ sed '3i\Test line 1' data4.txt #在第3行前面插入一行
This is line number 1.
This is line number 2.
Test line 1
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '3a\Test line 1' data4.txt #在第3行后面插入一行
This is line number 1.
This is line number 2.
This is line number 3.
Test line 1
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '$a\Test line 1' data4.txt  #符号$表示数据最后一行
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
Test line 1
xjh@ubuntu:~/iot/tmp$ sed '/number 2/i\Test line 1' data4.txt 
This is line number 1.
Test line 1
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '$i\Test line 1' data4.txt #使用文本模式的行寻址方式定位行
This is line number 1.
This is line number 2.
This is line number 3.
Test line 1
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '2i\  #在指定行前插入或者指定行后附加多行文本的方法
> this is a cat.\
> this is a dog.' data4.txt
This is line number 1.
this is a cat.
this is a dog.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$

4、修改命令c

该命令可以修改数据流中整行文本的内容,其用法与插入命令或者附加命令一致,把i或者a改为c即可,这里不再赘述。但值得注意的是,如果在c命令中使用地址区间,那么不会把该地址区间的每一行都改为新行,而是用新的一行来替换这个地址区间里的所有行。

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed '2,3c\This is a cat.' data4.txt 
This is line number 1.
This is a cat.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ 

5、转换字符y

转换字符y是唯一可以处理单个字符的sed编辑器命令,使用格式如下:

sed '[address]y/inchar/outchar/' file

这个命令会将inchar中的第n个字符转换为outchar中的第n个字符,直到处理inchar中的所有字符。使用该命令时,要求inchar和outchar的长度一样,否则会报错。

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed 'y/123/789/' data4.txt 
This is line number 7.
This is line number 8.
This is line number 9.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ 

6、打印命令

在替换命令s中提到,可以利用替换标志p来与-n选项,来显示sed编辑器修改过的行。另外也有3个命令能够打印数据流中的信息。

(1)利用p命令打印行,其最常见的用法是打印包含匹配文本模式的行,这需要结合-n选项。

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed -n '/number 3/p' data4.txt 
This is line number 3.
xjh@ubuntu:~/iot/tmp$ sed -n '2,3p' data4.txt 
This is line number 2.
This is line number 3.
xjh@ubuntu:~/iot/tmp$ sed -n '/number 3/{
> p
> s/This/It/
> }' data4.txt
This is line number 3. #如果不带p标志,因为用了-n选项,则修改后的内容不会被打印出来
xjh@ubuntu:~/iot/tmp$ sed -n '/number 3/{ #这个例子表示,利用打印命令,在修改前查看原先行的内容
> p
> s/This/It/p
> }' data4.txt
This is line number 3.
It is line number 3.
xjh@ubuntu:~/iot/tmp$

(2)利用等号命令打印行号,即打印行在数据流中的当前行号。

xjh@ubuntu:~/iot/tmp$ sed '=' data4.txt
1
This is line number 1.
2
This is line number 2.
3
This is line number 3.
4
This is line number 4.
xjh@ubuntu:~/iot/tmp$ sed -n '/number 2/{
> p
> =
> }' data4.txt
This is line number 2.
2
xjh@ubuntu:~/iot/tmp$ 

(3)利用小写的L打印行,该命令可以打印数据流中的文本和不可打印的ASCII字符。不可打印的ASCII字符在显示结果中,一般以反斜杆加其八进制值,或者以C语言风格的形式显示,比如\t。

xjh@ubuntu:~/iot/tmp$ cat data5.txt 
This	is	line	number	1. #这里故意留了一行
xjh@ubuntu:~/iot/tmp$ sed -n 'l' data5.txt 
This\tis\tline\tnumber\t1.$
$
xjh@ubuntu:~/iot/tmp$xjh@ubuntu:~/iot/tmp$ cat data5.txt 
This	is	line	number	1. #这里的间隔是按了tab键产生的,即\t这个制表符
This	is	line	number	2.
xjh@ubuntu:~/iot/tmp$ sed -n 'l' data5.txt
This\tis\tline\tnumber\t1.$    #\t表示制表符,$表示换行符
This\tis\tline\tnumber\t2.$
xjh@ubuntu:~/iot/tmp$ 

7、写入命令w

该命令可以将一个文件中的某些行(如果指定)或者将标准输入中的内容(默认情况),写入到另一个文件中。如果是将文件中的某些行写入到另一个文件,可以通过之前提到的两种行寻址方式,查找到要写入的行。注意是将哪个文件中的内容,写到哪一个另外的文件,即注意格式。

xjh@ubuntu:~/iot/tmp$ sed '2,3 w test.txt' data4.txt  #将data4.txt文件中的第2到第3行的内容,写到文件test.txt中
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ cat test.txt 
This is line number 2.
This is line number 3.
xjh@ubuntu:~/iot/tmp$ 

可以利用该命令,结合文本模式匹配方式,从某个文件中提取想要的数据,并写入到新文件中。

xjh@ubuntu:~/iot/tmp$ cat data6.txt 
name	age	height
xjh	18	176
xjq	25	180
zzm	45	160
xjh@ubuntu:~/iot/tmp$ sed -n '/xjh/w xjh.txt' data6.txt 
xjh@ubuntu:~/iot/tmp$ cat xjh.txt 
xjh	18	176
xjh@ubuntu:~/iot/tmp$

8、读取命令r

该命令会将数字文件中的所有文本行都插到数据流中。注意是读取哪个文件的内容,插到哪个另外的文件中,即注意格式。

xjh@ubuntu:~/iot/tmp$ cat data4.txt 
This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ cat data5.txt 
This	is	line	number	1.
This	is	line	number	2.
xjh@ubuntu:~/iot/tmp$ sed '/number 2/r data5.txt' data4.txt  #将data5,.txt的内容插入到data4.txt中指定的行的后面
This is line number 1.
This is line number 2.
This	is	line	number	1.
This	is	line	number	2.
This is line number 3.
This is line number 4.
xjh@ubuntu:~/iot/tmp$ 

该命令与删除命令配合使用,可以利用另一个文件中的数据来替代某个文件中的占位文本(即某个文本模板中的词语,利用该模板时,在该词语处添加内容)。

xjh@ubuntu:~/iot/tmp$ cat name.txt 
XJH
XJQ
ZZP
xjh@ubuntu:~/iot/tmp$ cat notice.txt 
Would the following people:
LIST
Please stand up!
xjh@ubuntu:~/iot/tmp$ sed '/LIST/{
> r name.txt
> d
> }' notice.txt
Would the following people:
XJH
XJQ
ZZP
Please stand up!
xjh@ubuntu:~/iot/tmp$ 

相关文章:

Shell命令——sed命令

以下内容整理于《linux命令行与shell脚本编程大全【第三版】》一书。 一、简介sed编辑器 1、sed编辑器的本质 sed是stream editor的缩写,中文意思是“流编辑器”。 sed编辑器是一个命令行编辑器,也就是可以在命令行上完成数据的处理(替换、…...

C语言练习 | 初学者经典练习汇(2)

目录 1、编写一个程序从1到100中,所有出现9的个数 2、分数求和 3、10个整形数字中选出最大值 4、打印9*9的乘法口诀 5、字符串逆序 6、计算一个数的每位之和(递归实现) 7、递归实现n的K次方 8、写个冒泡排序,把一个整形数组变成升序。 9、二进制…...

git分支

分支什么是分支在版本控制过程中,同时推进多个任务,为每个任务,我们就可以创建每个任务的单独分支。使用分支意味着程序员可以把自己的工作从开发主线上分离开来,开发自己分支的时候,不会影响主线分支的运行。对于初学…...

Java每天15道面试题 | redisII

1、什么是 Redis?简述它的优缺点? Redis 本质上是一个 Key-Value 类型的内存数据库,很像 memcached,整个数据库统统加载在内存当中进行操作,定期通过异步操作把数据库数据 flush 到硬盘上进行保存。因为是纯内存操作&a…...

浏览器渲染原理

阶段 - Parse 1、解析HTML,浏览器将从服务器获取到的HTML文件之后,会产生一个渲染任务,交给消息队列(EventLoop/MessageLoop)。 2、在事件循环机制的作用下,会将渲染任务交给主线程 3、主线程在获取到渲染…...

华为OD机试题 - 查找单入口空闲区域(JavaScript)| 含思路

华为OD机试题 最近更新的博客使用说明本篇题解:查找单入口空闲区域题目输入输出示例一输入输出说明示例二输入输出说明示例三输入输出说明示例四输入输出说明Code解题思路华为OD其它语言版本<...

制造型企业想要做好数字化改造,要注意以下几点!

很多企业在“工业4.0、智能制造、互联网”等概念满天飞的环境下迷失了方向&#xff0c;不知该如何下手&#xff0c;盲目跟风&#xff0c;看别人投自动化&#xff0c;自己也跟着投&#xff0c;看别人上信息化&#xff0c;自己也跟着上。 其实&#xff0c;智能制造也好&#xff…...

【蓝桥杯集训·每日一题】AcWing 1488. 最短距离

文章目录一、题目1、原题链接2、题目描述二、解题报告1、思路分析2、时间复杂度3、代码详解三、知识风暴Dijkstra算法一、题目 1、原题链接 1488. 最短距离 2、题目描述 有 N 个村庄&#xff0c;编号 1 到 N。 村庄之间有 M 条无向道路&#xff0c;第 i 条道路连接村庄 ai 和村…...

比亚迪:全球最大电动汽车制造商的坎坷成长之路

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 特斯拉&#xff08;TSLA&#xff09;首席执行官埃隆马斯克表示&#xff0c;特斯拉最接近的竞争对手可能是一家中国电动汽车公司。猛兽财经认为&#xff0c;沃伦•巴菲特支持的比亚迪&#xff08;0211&#xff09;可能是马斯…...

Java开发 - Quartz初体验

前言 在上一篇博客中&#xff0c;我们对单点登录有了初步了解&#xff0c;这也让我们独立做系统有了最基础的保障。但在业务开发中&#xff0c;总是会出现一些定期处理的任务&#xff0c;我们首先想到的是Timer&#xff0c;但由于其调度功能单一&#xff0c;我们实际并不会用它…...

无头盔开发vr XR Device Simulator操作(更新)

1.摄像机&#xff08;未开启TY键&#xff09; 平移 上下左右&#xff1a;右键鼠标&#xff0c;移哪去哪 前后&#xff1a;右键快速滚动鼠标滚轮 旋转 XOY平面旋转&#xff1a;右键按住鼠标滚轮滚动鼠标滚轮 XOZ\YOZ平面旋转&#xff1a;右键按住鼠标滚轮移动鼠标 2.左手右手&am…...

《C++代码分析》第二回:函数重载const char* ,char*,const char[],char[]汇编代码上的区别

一、前言 C相比C是支持函数重载的&#xff0c;现在我们详细探讨一下C函数重载与类方法承载。 二、案例代码 我们编译如下代码&#xff0c;同样的我们关闭代码优化&#xff0c;删除符号链接文&#xff08;.pdb&#xff09; #include "windows.h" #include "w…...

【学习笔记】深入理解JVM之垃圾回收机制

【学习笔记】深入理解JVM之垃圾回收机制 更多文章首发地址&#xff1a;地址 参考&#xff1a; 《深入理解JAVA虚拟机》第三版 第三章尚硅谷 第134 - 203 集参考文章&#xff1a;https://blog.csdn.net/qq_48435252/article/details/123697193 1、概念 &#x1f33b; 首先我们…...

49.在ROS中实现local planner(2)- 实现Purepersuit(纯跟踪)算法

48.在ROS中实现local planner&#xff08;1&#xff09;- 实现一个可以用的模板实现了一个模板&#xff0c;接下来我们将实现一个简单的纯跟踪控制&#xff0c;也就是沿着固定的路径运动&#xff0c;全局规划已经规划出路径点&#xff0c;基于该路径输出相应的控制速度 1. Pur…...

Allegro如何设通孔Pin和Via的消盘操作指导

Allegro如何设通孔Pin和Via的消盘操作指导 用Allegro做PCB设计的时候,除了可以在光绘设置里面设置内层通孔Pin和Via的消盘,在设计过程中,同样也可以设置消盘效果,以便实时显示,如下图 如何设置,具体操作如下 点击Setup点击Unused Pads Suppression...

Android工厂模式

工厂模式分为三种 :简单工厂模式 、工厂方法模式 、抽象工厂模式 。 目录 简单工厂模式 UML图 实现 使用场景&#xff1a; 优点 &#xff1a; 缺点&#xff1a; 工厂方法模式 UML图 实现 使用场景&#xff1a; 优点&#xff1a; 缺点&#xff1a; 抽象工厂模式 UM…...

神经网络硬件加速器-架构篇

架构设计 常规架构通常包括两种&#xff1a; 1、全流水线架构&#xff0c;顾名思义&#xff0c;将整个神经网络进行平铺&#xff0c;并对每一层进行优化设计&#xff0c;优点&#xff1a;实现高吞吐率和低延时。缺点&#xff1a;消耗大量硬件资源&#xff0c;通常无法跨网络或…...

Python raise用法(超级详细,看了无师自通)

是否可以在程序的指定位置手动抛出一个异常&#xff1f;答案是肯定的&#xff0c;Python 允许我们在程序中手动设置异常&#xff0c;使用 raise 语句即可。 大家可能会感到疑惑&#xff0c;即我们从来都是想方设法地让程序正常运行&#xff0c;为什么还要手动设置异常呢&#…...

1.SpringSecurity快速入门

*SpringScurity的核心功能: 认证:验证当前访问系统的是不是本系统的用户,并且要确认具体是哪个用户 授权:经过认证后判断当前用户是否有权限进行某个操作 *第一步:创建springboot工程 *第二步:引入SpringSecurity依赖 *第三步:写controller,访问对应的url:localhos…...

Graph Partition: Edge cut and Vertex cut

Graph PartitionEdge cut and Vertex cutEdge cutVertex cut实际如何进行点分割和边分割的呢&#xff1f;Graph store format情况1&#xff1a;按照边列表存储&#xff1a;情况2&#xff1a;按照邻接表存储&#xff1a;Edge cut and Vertex cut 图结构描述了数据流动&#xff…...

Javascript周学习小结(初识,变量,数据类型)

JS的三大书写方式行内式如图所示&#xff1a;几点说明&#xff1a;JS的行内式写在HTML的标签内部&#xff0c;(常以on开头)&#xff0c;如onclick行内式常常使用单引号括住字符串以区分HTML的双引号可读性差&#xff0c;不建议使用引号易出错&#xff0c;不建议使用特殊情况下使…...

C语言-基础了解-10-C函数

C函数 一、C函数 函数是一组一起执行一个任务的语句。每个 C 程序都至少有一个函数&#xff0c;即主函数 main() &#xff0c;所有简单的程序都可以定义其他额外的函数。 您可以把代码划分到不同的函数中。如何划分代码到不同的函数中是由您来决定的&#xff0c;但在逻辑上&…...

【LeetCode】剑指 Offer(16)

目录 题目&#xff1a;剑指 Offer 33. 二叉搜索树的后序遍历序列 - 力扣&#xff08;Leetcode&#xff09; 题目的接口&#xff1a; 解题思路&#xff1a; 代码&#xff1a; 过啦&#xff01;&#xff01;&#xff01; 写在最后&#xff1a; 题目&#xff1a;剑指 Offer …...

第三十九章 linux-并发解决方法二(互斥锁mutex)

第三十九章 linux-并发解决方法二&#xff08;互斥锁mutex&#xff09; 文章目录第三十九章 linux-并发解决方法二&#xff08;互斥锁mutex&#xff09;互斥锁的定义与初始化互斥锁的DOWN操作互斥锁的UP操作用count1的信号量实现的互斥方法还不是Linux下经典的用法&#xff0c;…...

脚本方式本地仓库jar包批量导入maven私服

脚本内容&#xff0c;将以下内容保存为mavenimport.sh&#xff0c;放置于需要上传的目录下&#xff0c;可以是顶层目录&#xff0c;或者某个分包的目录&#xff0c;若私服已有待上传的包&#xff0c;则执行会被替换 #!/bin/bash # copy and run this script to the root of th…...

【c++】引用的学习

引用的定义和声明 引用是一种别名&#xff0c;它允许使用与原变量相同的内存位置。在C中&#xff0c;引用是使用&符号来定义的。引用必须在定义时初始化&#xff0c;并且可以与原变量分别使用。 int a 10; int& b a; // 定义了一个引用b&#xff0c;它指向a引用的作用…...

linux 软件安装及卸载

1.联网在线安装及卸载ubuntu环境下&#xff1a;使用apt-get 工具apt-get install - 安装软件包apt-get remove - 移除&#xff08;卸载&#xff09;软件包CentOS环境下&#xff1a;使用yum工具 &#xff08;银河麒麟系统属于centos&#xff09;yum install - 安装软件包yum rem…...

XShell连接ubuntu20.04.LTS

1 下载XshellXShell官方下载地址打开XSHELL官方下载地址&#xff0c;我们可以选择【家庭和学校用户的免费许可证】&#xff0c;输入邮箱之后即可获得下载链接安装非常简单&#xff0c;跟着提示进行即可。2 连接ubuntu2.1 查看ubuntu的ip地址输入命令查看ip地址ifconfig刚开始可…...

【FPGA】Verilog:MSI/LSI 组合电路之解码器 | 多路分解器

写在前面&#xff1a;本章将理解编码器与解码器、多路复用器与多路分解器的概念&#xff0c;通过使用 Verilog 实现多样的解码器与多路分解器&#xff0c;通过 FPGA 并使用 Verilog 实现。 Ⅰ. 前置知识 0x00 解码器与编码器&#xff08;Decoder / Encoder&#xff09; 解码器…...

深入理解JDK动态代理原理,使用javassist动手写一个动态代理框架

文章目录一、动手实现一个动态代理框架1、初识javassist2、使用javassist实现一个动态代理框架二、JDK动态代理1、编码实现2、基本原理&#xff08;1&#xff09;getProxyClass0方法&#xff08;2&#xff09;总结写在后面一、动手实现一个动态代理框架 1、初识javassist Jav…...