sed全功略

特斯拉数字孪生4.0体系解析:从“数字镜像“到“持续进化“的造车革命 当每一辆汽车都拥有自己的“数字分身”,我们正见证的不仅是技术革新,更是整个制造业文明形态的跃迁。其数字孪生体已超越“数字镜像”的被动属性,成为。特斯拉年服务收入超1200美元/车的业绩表明,数字孪生正在将汽车从“交通工具”转变为“持续增值的智能终端”。构建起覆盖设计、制造、使用、服务全链条的虚拟镜像体系,将物理世界与数字世界的融合推向新高度。:特斯拉的实践证明,数字孪生已从“技术选项”升级为“战略必选项”。不仅重塑了汽车产品的价值创造逻辑,更预示着整个制造业向“元宇宙工业”演进的新范式。 阅读详情

1.sed用法介绍
s e d是一个非交互性文本流编辑器。它编辑文件或标准输入导出的文本拷贝。
• 抽取域。
• 匹配正则表达式。
• 比较域。
• 增加、附加、替换。
• 基本的s e d命令和一行脚本。
[notice]无论命令是什么, s e d并不与初始化文件打交道,它操作的只是一个拷贝,然后所有的改动如果没有重定向到一个文件,将输出到屏幕。

基本格式:

代码:
sed [-n] [-e] 'command' file(s) sed [-n] -f scriptfile file(s)

(1)sed怎样读取数据

s e d从文件的一个文本行或从标准输入的几种格式中读取数据,将之拷贝到一个编辑缓冲区,然后读命令行或脚本的第一条命令,并使用这些命令查找模式或定位行号编辑它。重复此过程直到命令结束。
(2)调用sed

调用s e d有三种方式:
a.在命令行键入命令; sed [选项] s e d命令输入文件
b.将s e d命令插入脚本文件,然后调用s e d; sed [选项] -f sed脚本文件输入文件
c.将s e d命令插入脚本文件,并使s e d脚本可执行。 sed脚本文件 [选项] 输入文件

2.sed选项
s e d选项如下:
-n 不打印;s e d不写编辑行到标准输出,缺省为打印所有行(编辑和未编辑)。p命令可以用来打印编辑行。
-f 如果正在调用s e d脚本文件,使用此选项。此选项通知s e d一个脚本文件支持所有的s e d命令,例如:sed -f myscript.sed input_file,这里m y s c r i p t . s e d即为支持s e d命令的文件。
-c 下一命令是编辑命令。使用多项编辑时加入此选项。如果只用到一条s e d命令,此选项无用,但指定它也没有关系。
-i 编辑原文件(此选项慎用,如果使用则原文件就会被修改,无法恢复)。

3.保存sed输出
a.重定向(下面将sed命令的所有输出至文件 output-file 中)

代码:
zhyfly@zhyfly:~$ sed 'some-sed-commands' input-file>output-file

b.
w 写文本到一个文件

代码:
[address [,address]]w filename
代码:
zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '1,2w test.bak' test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ cat test.bak The honeysuckle band played all night long for only $90. It was an evening of splendid music and company.

另外,同样
r 从另一个文件中读文本

代码:
address r filename

4.sed基础用法
使用sed在文件中查询文本的方式:
sed浏览输入文件时,缺省从第一行开始,有两种方式定位文本:
a. 使用行号,可以是一个简单数字,或是一个行号范围。
b. 使用正则表达式。
例:
x #为一行号,如1
x,y #表示行号范围从x到y,如2,5表示从第2行到第5行
/pattern/ #查询包含模式的行。例如/disk/或/[a-z]/
/pattern/pattern/ #查询包含两个模式的行。例如/disk/disks/
/pattern/,x #在给定行号上查询包含模式的行。如/ribbon/,3
x,/pattern/ #通过行号和模式查询匹配行。3,/vdu/
x,y! #查询不包含指定行号x和y的行。1,2!

基本sed编辑命令:
sed编辑命令
p 打印匹配行
= 显示文件行号
a/ 在定位行号后附加新文本信息
i/ 在定位行号后插入新文本信息
d 删除定位行
c/ 用新文本替换定位文本
s 使用替换模式替换相应模式
r 从另一个文件中读文本
w 写文本到一个文件
q 第一个模式匹配完成后推出或立即推出
l 显示与八进制A S C I I代码等价的控制字符
{ } 在定位行执行的命令组
n 从另一个文件中读文本下一行,并附加在下一行
g 将模式2粘贴到/pattern n/
y 传送字符
n 延续到下一输入行;允许跨行的模式匹配语句

举例:

代码:
zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.
代码:
zhyfly@zhyfly:~/bash$ sed -e '1p' test.txt The honeysuckle band played all night long for only $90. The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -n -e '1p' test.txt The honeysuckle band played all night long for only $90.
代码:
zhyfly@zhyfly:~/bash$ sed -n -e '2p' test.txt It was an evening of splendid music and company.
代码:
zhyfly@zhyfly:~/bash$ sed -n -e '2,3p' test.txt It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00.
代码:
zhyfly@zhyfly:~/bash$ sed -n -e '/company/p' test.txt It was an evening of splendid music and company.
代码:
zhyfly@zhyfly:~/bash$ sed -n -e '2,/23:00/p' test.txt It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00.
代码:
zhyfly@zhyfly:~/bash$ sed -n -e '2,3!p' test.txt The honeysuckle band played all night long for only $90. The local nurse Miss P.Neave was in attendance.
代码:
zhyfly@zhyfly:~/bash$ sed -e '=' test.txt 1 The honeysuckle band played all night long for only $90. 2 It was an evening of splendid music and company. 3 Too bad the disco floor fell through at 23:00. 4 The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -n -e '=' test.txt 1 2 3 4 zhyfly@zhyfly:~/bash$ sed -n -e '/music/p' test.txt It was an evening of splendid music and company. zhyfly@zhyfly:~/bash$ sed -n -e '/music/=' test.txt 2 zhyfly@zhyfly:~/bash$ sed -n -e '/music/p' -e '/music/=' test.txt It was an evening of splendid music and company. 2 zhyfly@zhyfly:~/bash$ sed -e '=;p' test.txt 1 The honeysuckle band played all night long for only $90. The honeysuckle band played all night long for only $90. 2 It was an evening of splendid music and company. It was an evening of splendid music and company. 3 Too bad the disco floor fell through at 23:00. Too bad the disco floor fell through at 23:00. 4 The local nurse Miss P.Neave was in attendance. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -n -e '=;p' test.txt 1 The honeysuckle band played all night long for only $90. 2 It was an evening of splendid music and company. 3 Too bad the disco floor fell through at 23:00. 4 The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -n -e '=' -e 'p' test.txt 1 The honeysuckle band played all night long for only $90. 2 It was an evening of splendid music and company. 3 Too bad the disco floor fell through at 23:00. 4 The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$

附加 [address]a/附加内容 #缺省放在每一行后面

代码:
zhyfly@zhyfly:~/bash$ sed -e 'a/this line will be added to the end of each line!oooooooooo' test.txt The honeysuckle band played all night long for only $90. this line will be added to the end of each line!oooooooooo It was an evening of splendid music and company. this line will be added to the end of each line!oooooooooo Too bad the disco floor fell through at 23:00. this line will be added to the end of each line!oooooooooo The local nurse Miss P.Neave was in attendance. this line will be added to the end of each line!oooooooooo zhyfly@zhyfly:~/bash$ sed -e '/music/a/this line will be added to the end of the matching line!oooooooooo' test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. this line will be added to the end of the matching line!oooooooooo Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.

插入 [address]i/插入内容 #缺省放在每一行前面

代码:
zhyfly@zhyfly:~/bash$ sed -e 'i/this line will be inserted to the begin of each line!oooooooooo' test.txt this line will be inserted to the begin of each line!oooooooooo The honeysuckle band played all night long for only $90. this line will be inserted to the begin of each line!oooooooooo It was an evening of splendid music and company. this line will be inserted to the begin of each line!oooooooooo Too bad the disco floor fell through at 23:00. this line will be inserted to the begin of each line!oooooooooo The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '/music/i/this line will be inserted to the begin of the matching line!oooooooooo' test.txt The honeysuckle band played all night long for only $90. this line will be inserted to the begin of the matching line!oooooooooo It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.

更改行 [address]c/更改后整行内容 #缺省修改每一行

代码:
zhyfly@zhyfly:~/bash$ sed -e 'c/this line will be modified to the each line!oooooooooo' test.txt this line will be modified to the each line!oooooooooo this line will be modified to the each line!oooooooooo this line will be modified to the each line!oooooooooo this line will be modified to the each line!oooooooooo zhyfly@zhyfly:~/bash$ sed -e '/music/c/this line will be modified to the matching line!oooooooooo' test.txt The honeysuckle band played all night long for only $90. this line will be modified to the matching line!oooooooooo Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.

删除定位行

代码:
zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '/music/d' test.txt The honeysuckle band played all night long for only $90. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.

5.sed高级用法---替换
替换 [code][address]s/old/new/g[code]

[address]s/pattern/replacement #the first occurrence on the address(缺省所有行)
[address]s/pattern/replacement/g #all occurrences on the address(缺省所有行)

代码:
zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e 's/h/ooooo/' test.txt Toooooe honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad toooooe disco floor fell through at 23:00. Toooooe local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e 's/h/ooooo/g' test.txt Toooooe ooooooneysuckle band played all nigooooot long for only $90. It was an evening of splendid music and company. Too bad toooooe disco floor fell tooooorougooooo at 23:00. Toooooe local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '1,2s/h/ooooo/' test.txt Toooooe honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '1,2s/h/ooooo/g' test.txt Toooooe ooooooneysuckle band played all nigooooot long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '//$/s/h/ooooo/g' test.txt Toooooe ooooooneysuckle band played all nigooooot long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '/^It/,/23:00/s/l/ooooo/g' test.txt The honeysuckle band played all night long for only $90. It was an evening of spoooooendid music and company. Too bad the disco fooooooor feoooooooooo through at 23:00. The local nurse Miss P.Neave was in attendance.

使用替换修改字符串 &

代码:
zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e 's/$90/&230/g' test.txt The honeysuckle band played all night long for only $90230. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e 's/90/120,&/g' test.txt The honeysuckle band played all night long for only $120,90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance.

分隔符变换(避免产生歧义)

代码:
zhyfly@zhyfly:~/bash$ echo $PWD /home/zhyfly/bash zhyfly@zhyfly:~/bash$ echo $PWD|sed -e 's:/:@:g' @home@zhyfly@bash

规则表达式混乱
题目
zhyfly@zhyfly:~/bash$ cat test
This</b> is what <b>I</b> meant.
想要得到的答案:
This is what I meant.
错误解法:

代码:
zhyfly@zhyfly:~/bash$ cat test This</b> is what <b>I</b> meant. zhyfly@zhyfly:~/bash$ sed -e 's/<.*>//g' test This meant.

正确解法:

代码:
zhyfly@zhyfly:~/bash$ sed -e 's/<[^>]*>//g' test This is what I meant.

题目
要用sed把字符“/”转化成“'”该怎么写?
错误解法:

代码:
zhyfly@zhyfly:~/bash$ echo "hello/hh/haha" hello/hh/haha zhyfly@zhyfly:~/bash$ echo "hello/hh/haha"|sed -e 's////'/g' > > bash: unexpected EOF while looking for matching `'' bash: syntax error: unexpected end of file zhyfly@zhyfly:~/bash$ echo "hello/hh/haha"|sed -e 's/////'/g' > > bash: unexpected EOF while looking for matching `'' bash: syntax error: unexpected end of file

正确解法:

代码:
zhyfly@zhyfly:~/bash$ echo "hello/hh/haha"|sed -e 's////'"'"'/g' hello'hh'haha zhyfly@zhyfly:~/bash$

你看出来了吗?

更多字符匹配:
'[a-x]*'
这将匹配零或多个全部为 'a'、'b'、'c'...'v'、'w'、'x' 的字符。另外,可以使用 '[:space:]' 字符类来匹配空格。
以下是可用字符类的相当完整的列表:
字符类 描述

代码:
[:alnum:] 字母数字 [a-z A-Z 0-9] [:alpha:] 字母 [a-z A-Z] [:blank:] 空格或制表键 [:cntrl:] 任何控制字符 [:digit:] 数字 [0-9] [:graph:] 任何可视字符(无空格) [:lower:] 小写 [a-z] [:print:] 非控制字符 [:punct:] 标点字符 [:space:] 空格 [:upper:] 大写 [A-Z] [:xdigit:] 十六进制数字 [0-9 a-f A-F]

域
关于域应用一个较复杂的例子讲解
题目:
[file1.txt]
1C2
1C3
1C31
1C32
1C4
2C3
2C4
1D1
1D10
1D12
1D2
1D3
1D31
1RC2
1RC20
1RC21
1RC3
1RC31
1WR1
1WR2
1WR20
1WR21
1WR23

排序后
[file2.txt]
1 C 2
1 C 3
2 C 3
1 C 4
2 C 4
1 C 31
1 C 32
1 D 1
1 D 2
1 D 3
1 D 10
1 D 12
1 D 31
1 RC 2
1 RC 3
1 RC 20
1 RC 21
1 RC 31
1 WR 1
1 WR 2
1 WR 20
1 WR 21
1 WR 23


规律:将每行分成三部分: “数字1” “字符串” “数字2”(即三个域)
第一、三字段按numberic顺序排序,中间部分按字母排序 ,优先级顺序2 3 1
解答思路:
首先需要将文件的每行分成三个域,这就利用到sed的分域功能,可以这样分(其中包含分域的格式):

代码:
/^/([0-9]*/)/([A-Z]*/)/([0-9]*/)//1 /2 /3/
代码:
zhyfly@zhyfly:~/bash$ cat file1.txt 1C2 1C3 1C31 1C32 1C4 2C3 2C4 1D1 1D10 1D12 1D2 1D3 1D31 1RC2 1RC20 1RC21 1RC3 1RC31 1WR1 1WR2 1WR20 1WR21 1WR23

分域后

代码:
zhyfly@zhyfly:~/bash$ sed -e 's/^/([0-9]*/)/([A-Z]*/)/([0-9]*/)//1 /2 /3 /g' file1.txt 1 C 2 1 C 3 1 C 31 1 C 32 1 C 4 2 C 3 2 C 4 1 D 1 1 D 10 1 D 12 1 D 2 1 D 3 1 D 31 1 RC 2 1 RC 20 1 RC 21 1 RC 3 1 RC 31 1 WR 1 1 WR 2 1 WR 20 1 WR 21 1 WR 23

排序后

代码:
zhyfly@zhyfly:~/bash$ sed -e 's/^/([0-9]*/)/([A-Z]*/)/([0-9]*/)//1 /2 /3 /g' file1.txt|sort +1 -2 +2n +0 -1 1 C 2 1 C 3 2 C 3 1 C 4 2 C 4 1 C 31 1 C 32 1 D 1 1 D 2 1 D 3 1 D 10 1 D 12 1 D 31 1 RC 2 1 RC 3 1 RC 20 1 RC 21 1 RC 31 1 WR 1 1 WR 2 1 WR 20 1 WR 21 1 WR 23

下面的例子比较复杂:
题目
文件内容file.txt:
123456 345678 2005-05-06 123456
123456 234567 2003-5-6 234567
345555 987644 2003-4-23 543333
555555 999999 2004-11-5 999999

要将第四列数据变成正常的年月日,将2003-5-6 变成2003-05-0;
2003-4-23变成2003-04-23; 2004-11-5变成 2004-11-05

解答
首先将需要改变的部分分域

代码:
/-/([0-9]/)-/-0/1-/ #月 /-/([0-9]/) /-0/1 / #日

注意实现起来又有多种方法:

代码:
zhyfly@zhyfly:~/bash$ cat file.txt 123456 345678 2005-05-06 123456 123456 234567 2003-5-6 234567 345555 987644 2003-4-23 543333 555555 999999 2004-11-5 999999 zhyfly@zhyfly:~/bash$ sed -e 's/-/([0-9]/)-/-0/1-/g' -e 's/-/([0-9]/) /-0/1 /g' file.txt 123456 345678 2005-05-06 123456 123456 234567 2003-05-06 234567 345555 987644 2003-04-23 543333 555555 999999 2004-11-05 999999 zhyfly@zhyfly:~/bash$ sed -e 's/-/([0-9]/)-/-0/1-/g;s/-/([0-9]/) /-0/1 /g' file.txt 123456 345678 2005-05-06 123456 123456 234567 2003-05-06 234567 345555 987644 2003-04-23 543333 555555 999999 2004-11-05 999999 zhyfly@zhyfly:~/bash$ sed -e :a -e 's/-/([0-9]/)/([- ]/)/-0/1/2/;ta' file.txt 123456 345678 2005-05-06 123456 123456 234567 2003-05-06 234567 345555 987644 2003-04-23 543333 555555 999999 2004-11-05 999999

注:
:a - label
ta - goto to :a to rerun sed if the last sed is finished successfully.
简单说, 就是循环。

多个命令常用的方法
主要有
a.利用多个-e选项
b.利用 ;
c.使用脚本文件
上面几种方法,前面也有提到。

代码:
zhyfly@zhyfly:~/bash$ sed -e '2,3s/a/ooooo/g' -e '2,3s/d/ddddd/g' test.txt The honeysuckle band played all night long for only $90. It wooooos ooooon evening of splendddddiddddd music ooooonddddd compooooony. Too boooooddddd the dddddisco floor fell through ooooot 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -e '2,3s/a/ooooo/g;2,3s/d/ddddd/g' test.txt The honeysuckle band played all night long for only $90. It wooooos ooooon evening of splendddddiddddd music ooooonddddd compooooony. Too boooooddddd the dddddisco floor fell through ooooot 23:00. The local nurse Miss P.Neave was in attendance.

前两种方法比较简单,下面重点讲一下第三种方法
首先
创建sed脚本文件-->赋予执行权限-->执行文件

代码:
zhyfly@zhyfly:~/bash$ cat sub.sed #!/bin/sed -f 2,3s/a/ooooo/g 2,3s/d/ddddd/g zhyfly@zhyfly:~/bash$ sudo chmod +x sub.sed zhyfly@zhyfly:~/bash$ cat test.txt The honeysuckle band played all night long for only $90. It was an evening of splendid music and company. Too bad the disco floor fell through at 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ ./sub.sed test.txt The honeysuckle band played all night long for only $90. It wooooos ooooon evening of splendddddiddddd music ooooonddddd compooooony. Too boooooddddd the dddddisco floor fell through ooooot 23:00. The local nurse Miss P.Neave was in attendance. zhyfly@zhyfly:~/bash$ sed -f sub.sed test.txt The honeysuckle band played all night long for only $90. It wooooos ooooon evening of splendddddiddddd music ooooonddddd compooooony. Too boooooddddd the dddddisco floor fell through ooooot 23:00. The local nurse Miss P.Neave was in attendance.
使用C# HslCommunication库实现三菱PLC通信(含完整代码示例) 在工业自动化开发中,上位机与PLC的通信是关键环节。HslCommunication库是一个开源的.NET工业通信库,支持三菱、西门子、欧姆龙等多个品牌PLC的通信协议。本文将演示如何通过库实现C#程序与三菱PLC的通信,并提供完整的代码示例。 阅读详情

相关推荐

骨架动作识别新突破:CTR-GCN的通道拓扑优化策略解析

本文深入解析了CTR-GCN在骨架动作识别中的通道拓扑优化策略。通过引入通道级拓扑细化,CTR-GCN克服了传统GCN共享拓扑结构的局限性,显著提升了动作识别的准确率。文章详细介绍了CTR-GCN的三大核心组件设计,包括特征变换模块、通道拓扑建模和通道聚合技术,并提供了实战调参经验和模型压缩技巧,为计算机视觉领域的研究者和开发者提供了有价值的参考。

weixin_27310417的博客 192

#SED#sed 简明教程

转载自:http://coolshell.cn/articles/9104.html,陈皓。 awk于1977年出生,今年36岁本命年,sed比awk大2-3岁,awk就像林妹妹,sed就是宝玉哥哥了。所以 林妹妹跳了个Topless,他的哥哥sed坐不住了,也一定要出来抖一抖。 sed全名叫stream editor,流编辑器,用程序的方式来编辑文本,相当的hacker啊。sed基本

duqi_yc的专栏 1166

从URDF到Gazebo:一个完整的ROS2机械臂仿真与运动控制实战指南

本文提供了一个完整的ROS2机械臂仿真与运动控制实战指南。详细讲解了从URDF建模、ROS2 Control配置到Gazebo物理仿真的全流程,重点介绍了如何利用MoveIt2快速搭建高级运动规划系统,并解决实际部署中的常见问题,帮助开发者高效、安全地进行机器人算法验证与开发。

red88的博客 572

Linux 运维文本神器:sed 流编辑器核心用法与实战精讲

Linux 运维文本神器:sed 流编辑器核心用法与实战精讲

https://ophome.blog.youkuaiyun.com,在IT行业有多年的工作经验,尤其是在Python、Linux、负载均衡、Nginx和服务器运维等领域。 543

三极管特性曲线看不懂?手把手教你用Multisim仿真分析放大电路频率响应

本文针对模拟电路初学者,详细讲解如何利用Multisim软件进行电路仿真,将抽象的三极管特性曲线与放大电路频率响应分析变得直观可视。通过手把手教学,指导读者从导入三极管SPICE模型、仿真输出特性曲线,到分析动态工作点,最终使用波特图仪深入分析频率响应并进行补偿设计,有效帮助理解电路原理并指导实践调试。

weixin_29230059的博客 122

永磁同步电机解耦控制实战:从电流反馈到内模解耦的算法演进与选型指南

本文深入探讨了永磁同步电机高性能驱动中的核心挑战——交叉耦合问题,并对比分析了电流反馈解耦和内模解耦两大主流算法的原理、性能与适用场景。文章指出,电流反馈解耦动态响应快但对参数敏感,内模解耦鲁棒性更强但略有滞后,为工程师在不同应用需求下的算法选型提供了清晰的实战指南。

weixin_29039773的博客 263

Linux sed 命令 详解

sed是一个基于模式匹配对文本进行过滤或修改的流编辑器。替换文本内容删除指定行插入或追加新内容打印特定行使用正则表达式进行高级匹配多条命令组合处理与交互式编辑器(如vim)不同,sed是非交互式的,适合在脚本中自动执行批量文本处理任务。sed是 Linux 下非常实用的文本处理利器,掌握其基本命令和正则表达式技巧,可以大幅提升你在日常运维、日志分析、自动化脚本编写等方面的效率。grep查找,sed修改,awk分析 —— 这就是 Linux 文本处理三剑客!

h a 6 6 6 c k 为 你解决复杂难题! 2751

红米12C刷机避坑指南:NV数据损坏的修复与系统版本选择

本文提供了红米12C刷机过程中避免NV数据损坏的详细指南,涵盖系统版本选择、SP刷机工具使用和fastboot命令修复。重点分析了NV数据损坏的原因与表现,并给出通过工程固件和深度修复技巧解决基带未知、IMEI丢失等问题的实操方案,帮助用户安全完成刷机。

cuda7parallel的博客 1074

sed命令详解+示例(1),开发8年的老Linux运维才知道

每行文本拆分为“第1个字符”、“第2个字符”、“剩下的所有字符”三个部分,然后通过替换操作重排顺序为“2-1-3”:# sed -r ‘s/^(.)(.)(.*)/\2\1\3/’ nssw.txt。调整/var/ftp/pub目录权限,允许ftp写入;将第一个字符与最后一字符对调:sed -r “s/^(.)(.)(.*)(.)(.)$/\1\4\3\2\5/” nssw.txt。# sed -i ‘/^id:/s/3/5/’ /etc/inittab //将默认运行级别修改为5。

1505

基于自抗扰控制的虚拟同步发电机二次调频控制研究

摘要:本文针对高比例可再生能源并网导致的电力系统频率稳定性问题,提出基于自抗扰控制(ADRC)的虚拟同步发电机(VSG)二次调频控制策略。通过分析VSG工作原理和传统调频方法的不足,设计了非线性ADRC和线性ADRC两种控制器,详细阐述了参数整定方法。仿真结果表明,该策略能有效消除频率稳态偏差,提升系统抗扰能力,为分布式电源参与电网调频提供了新思路。 关键词:虚拟同步发电机;自抗扰控制;二次调频;频率调节;抗扰能力

huanghm88的专栏 243

一文速览:大模型语料构建与基础训练全流程实战指南

因为模型只有看到足够丰富、高质量的数据,才能真正学到“真本事”,展现出更强大的泛化能力,也就是能够在全新的场景和任务下,做出准确的推理和判断。我们日常做饭的时候,通常会先把买回来的菜仔细清洗干净,把坏掉的叶子、泥土、杂质等去除掉。同理,训练大模型的数据就像我们的食材,如果不干净,就会影响模型的学习效果,甚至训练出逻辑紊乱的模型。在大模型的世界里,有一句名言:“Garbage in, Garbage out”,翻译过来就是“垃圾输入,垃圾输出”,说白了,就是给模型喂的是什么数据,它学到的就是什么知识。

master_hunter的博客 1668

shell脚本之sed详解 (sed命令 , sed -e , sed s/ new / old / ... )

(一)Sed是一个非交互性文本流编辑器。它编辑文件或标准输入导出的文本拷贝。vi中的正则表达式命令在sed中大多可以通用。##sed常用选项-e script 指定sed编辑命令-f scriptfile 指定的文件中是sed编辑命令-n 寂静模式,抑制来自sed命令执行过程中的冗余输出信息,比如只显示那些被改变的行。-i[SUFFIX], –in-place[=SUFFIX] 替换和备份源文件edit files in place (makes backup if extension supplied)#

Jerry00713的博客 1万+

Android NDK/JNI面试题大全及参考答案(3万字长文)

是一套工具集合,它允许开发者为Android平台编写原生应用程序或者应用程序的部分模块。NDK 主要用于开发那些需要高性能计算的应用程序,例如游戏引擎、图像处理软件或音频/视频编码解码器等。通过使用 C 或 C++ 编写代码,开发者可以利用硬件加速功能,提高应用性能。NDK 提供了一系列工具来帮助开发者完成从源代码到可执行文件的整个过程,包括编译、链接、调试等功能。

大模型大数据攻城狮的专栏 1256

sed新手使用进阶全功略!

<br />标题: ***sed新手使用进阶全功略!***<br /> 看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助!<br /> 注:sed使用中除了多个命令时, -e选项一般可以省略!<br />基础:<br /> 正则表达式(Regular Expression)<br /> 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶引用: - 錨點(anchor)

503

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

sed新手使用进阶全功略[转]

看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助! 注:sed使用中除了多个命令时, -e选项一般可以省略! 基础: 正则表达式(Regular Expression) 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶 引用: ...

weixin_30892987的博客 139

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

[ZZ]sed新手使用进阶全功略!

zz from http://www.linuxsir.org/bbs/showthread.php?t=189620作者:zhy2111314  看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助!注:sed使用中除了多个命令时, -e选项一般可以省略!基础:正则表达式(Regular Expression)在学习sed前,首先了

shuiyu的blog 733

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

sed新手使用进阶全功略(转)

本贴来自http://www.linuxsir.org/bbs/showthread.php?t=189620标题: ***sed新手使用进阶全功略!*** 看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助!注:sed使用中除了多个命令时, -e选

吴遥的专栏 876

***sed新手使用进阶全功略!***

http://www.linuxsir.org/bbs/showthread.php?t=189620 看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助! 注:sed使用中除了多个命令时, -e选项一般可以省略! 基础

wfreehorse的专栏 386

标题: ***sed新手使用进阶全功略!***

看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助!注:sed使用中除了多个命令时, -e选项一般可以省略!基础:正则表达式(Regular Expression)在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶 引用: - 錨點(anch...

weixin_33802505的博客 162

ed新手使用进阶全功略

基础:正则表达式(Regular Expression)在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶引用:- 錨點(anchor)用以標識 RE 於句子中的位置所在. 常見有:^: 表示句首. 如 ^abc 表示以 abc 開首的句子.$: 表示句尾. 如 abc$ 表示以 abc 結尾的句子.\&lt;: 表示詞首. 如 \&lt...

weixin_34183910的博客 160

sed 高级

基础: 正则表达式(Regular Expression) 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶 引用: - 錨點(anchor) 用以標識 RE 於句子中的位置所在. 常見有: ^: 表示句首. 如 ^abc 表示以 abc 開首的句子. $: 表示句尾. 如 abc$ 表示以 abc 結尾的句子. /: 表示詞尾. 如 abc/> 表示以 abc 結尾的詞. - 修飾字符(modifier) 獨立表示時本

jxfgh的专栏 749

sed详解+实例

注:sed使用中除了多个命令时, -e选项一般可以省略! 基础: 正则表达式(Regular Expression) 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶 引用: - 錨點(anchor) 用以標識 RE 於句子中的位置所在. 常見有: ^: 表示句首. 如 ^abc 表示以 abc 開首的句子. $: 表示...

threeallsearchsparkkangouptake 280

sed使用心得

原始文件内容 A BC eee BluefinAsserts.verifyTrue(true, "25899"); BluefinAsserts.verifyTrue(true, "258xY399b"); BluefinAsserts.verifyTrue(isFound, "verify xxx"); BluefinAsserts.assertTrue(isFound, "V

xiqobai的专栏 793

sed总结

看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助! 注:sed使用中除了多个命令时, -e选项一般可以省略! 基础: 正则表达式(Regular Expression) 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知道下面这些,如果不了解正则表达式,那么您将很难进阶引用: - 錨點(anchor) 用以標識 RE

奔跑的路 723

shell sed

http://www.linuxsir.org/bbs/showthread.php?t=189620 看了各个linux 论坛的帖子,感觉sed的介绍不少,但有点零乱,在这里整理一下,希望能对学习者有所帮助! 注:sed使用中除了多个命令时, -e选项一般可以省略! 基础: 正则表达式(Regular Expression) 在学习sed前,首先了解RE的基本知识,大体上最基本也需要知

729
上一篇: 获取进程的CPU使用情况
下一篇: Sed学习笔记
nodeadbird520
博客等级 码龄19年 20粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值