<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>archive</title><link>https://archive-w.netlify.app/devops/os/util/</link><description>Recent content on archive</description><generator>Hugo</generator><language>zh-CN</language><atom:link href="https://archive-w.netlify.app/devops/os/util/index.xml" rel="self" type="application/rss+xml"/><item><title/><link>https://archive-w.netlify.app/devops/os/util/grep/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/grep/</guid><description>&lt;h2 id="简介">
 简介
 &lt;a class="anchor" href="#%e7%ae%80%e4%bb%8b">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">grep(global regular expression print):
grep 主要用来查找，过滤，grep家族总共有三个：grep，egrep，fgrep。egrep = grep -E 扩展的正则表达式。

1、基本的正则表达式（Basic Regular Expression 又叫 Basic RegEx 简称 BREs）
2、扩展的正则表达式（Extended Regular Expression 又叫 Extended RegEx 简称 EREs）
3、Perl 的正则表达式（Perl Regular Expression 又叫 Perl RegEx 简称 PREs）

***********************************************************
 grep 默认 BREs, -E EREs, -P PREs
 egrep 默认 EREs, -P PREs
 sed 默认 BREs,-r EREs
 awk 默认 EREs
***********************************************************
&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="常用选项">
 常用选项
 &lt;a class="anchor" href="#%e5%b8%b8%e7%94%a8%e9%80%89%e9%a1%b9">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># -E : 开启扩展的正则表达式
# -i : 忽略大小写（ignore case）
# -v : 反向选择（invert）
# -n : 显示行号
# -o : 只显示匹配到的内容
# -w : 被匹配的文本只能是单词，不是某一部分，`like` 不会匹配liker
# -c : 显示匹配到多少行，与-cv使用表示反向匹配行数
# --color : 将匹配到的内容以颜色高亮显示
# -A n : 显示字符所在行及其后n行，after
# -B n : 显示字符所在行及其前n行，before
# -C n : 显示字符前后n行，context

grep &amp;quot;root&amp;quot; /etc/passwd
grep -n &amp;quot;root&amp;quot; /etc/passwd
grep -cv &amp;quot;root&amp;quot; /etc/passwd
grep -o &amp;quot;root&amp;quot; /etc/passwd
grep -A 2 &amp;quot;core id&amp;quot; /proc/cpuinfo
&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="模式部分">
 模式部分
 &lt;a class="anchor" href="#%e6%a8%a1%e5%bc%8f%e9%83%a8%e5%88%86">#&lt;/a>
&lt;/h2>
&lt;pre>&lt;code>1. 直接输入要匹配的字符串，可以使用fgrep(fast grep)代替来提高查找速度
2. 使用基本正则表达式
 * 匹配字符
 . :任意字符
 [abc] : 表示匹配一个字符，这个字符必须是abc中的一个。
 [^123] : 匹配一个除了123以外的字符
 [a-zA-Z] : 等价于[[:alpha:]]
 [0-9] : 等价于[[:digit:]]
 [a-zA-Z0-9] : 等价于 [[:alnum:]]
 tab,space : 等价于 [[:space:]]
 [A-Z] : [[:upper:]]
 [a-z] : [[:lower:]]
 标点符号 : [[:punct:]]
 
 # grep &amp;quot;hello.&amp;quot; demo.c
 # grep &amp;quot;hello[[:upper:]]&amp;quot; demo.c
 # grep &amp;quot;hello[^[:upper:]][[:digit:]]&amp;quot; demo.c
 # grep &amp;quot;hell[a-z]&amp;quot; demo.c
 # grep &amp;quot;hell[a-z][[:punct:]]&amp;quot; demo.c
 
 * 匹配次数：
 \{m,n\} : 至少m,至多n次
 \? : 0 或 1 次
 * : 任意次
 
 # grep &amp;quot;/.*sh&amp;quot; /etc/passwd
 # grep &amp;quot;/.\{0,2\}sh&amp;quot; /etc/passwd
 # grep -w &amp;quot;.\{0,2\}sh&amp;quot; /etc/passwd
 
 * 位置锚定:
 ^ : 锚定行首
 $ : 锚定行尾： `^$`用于匹配空白行（没有空格）
 \b 或 \&amp;lt; : 单词词首
 \b 或 \&amp;gt; : 单词词尾
 \B : 与\b 相反 `beer/B` 不是以beer结尾
 
 # grep &amp;quot;h&amp;quot; /etc/passwd
 # grep &amp;quot;h$&amp;quot; /etc/passwd
 # grep &amp;quot;\&amp;lt;sh&amp;quot; /etc/passwd
 # grep &amp;quot;\Bsh\b&amp;quot; /etc/passwd
 
 * 分组及引用：
 \(string\) : 将string作为一个整体方便后面引用
 \n : 第几个引用，0表示本记录，从1开始
 
 # grep &amp;quot;^\(.\{1\}\).*\1$&amp;quot; /etc/passwd
 # grep &amp;quot;^\([[:alpha:]]\).*\1$&amp;quot; /etc/passwd

 * 分组后不引用 (?:), 参考Reference
 
 * 零宽断言：
 (?=pattern) 正向先行断言（正前瞻）
 (?&amp;lt;=pattern) 正向后行断言（正后顾）
 (?!pattern) 负向先行断言（负前瞻）
 (?&amp;lt;!=pattern)负向后行断言（负后顾）
 
 # 我爱祖国，我是祖国的花朵
 # 祖国(?=的花朵)
 # (?&amp;lt;=我爱)祖国
 # 祖国(?!的花朵)
 # (?&amp;lt;!我爱)祖国

3. 扩展正则表达式(-E | egrep)
 `?` `+` `|` `()` `{}`
&lt;/code>&lt;/pre>
&lt;h2 id="外链">
 外链
 &lt;a class="anchor" href="#%e5%a4%96%e9%93%be">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="31-rubularcom外链">
 3.1 rubular.com外链
 &lt;a class="anchor" href="#31-rubularcom%e5%a4%96%e9%93%be">#&lt;/a>
&lt;/h3>
&lt;ul>
&lt;li>


 &lt;a href="https://rubular.com/r/N5s1264MOiJzgG" rel="noopener" target="_blank">祖国(?=的花朵)&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://rubular.com/r/k2Aj5zYb8VsdRl" rel="noopener" target="_blank">(?&amp;lt;=我爱)祖国&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://rubular.com/r/n2r84kmPHbapfm" rel="noopener" target="_blank">祖国(?!的花朵)&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://rubular.com/r/knBZziOjn0XBVA" rel="noopener" target="_blank">(?&amp;lt;!我爱)祖国&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://rubular.com/r/2F8fmkJKc64yMw" rel="noopener" target="_blank">电话号码&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;h3 id="32-regex-学习记录">
 3.2 RegEx 学习记录
 &lt;a class="anchor" href="#32-regex-%e5%ad%a6%e4%b9%a0%e8%ae%b0%e5%bd%95">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">3.2.1正则匹配同时包含两个字符，不分先后顺序,https://rubular.com/r/C8klIhBII08CXN
^(?=.*?test)(?=.*?bash).*$
 以下下列子可能有助于理解:如果需要匹配字符，需要定界。
 ^(?=.*?test)(?=.*?bash).{9,}$
 ^(?=.*?test).{0,}(?=bash)
 ^(?=.*test)(?=.*bash)
 ^(?=.*test)(?=.*bash).{2}


3.2.2 正则不过滤但深色显示
cat abcdef | grep &amp;quot;content\|$&amp;quot;

3.2.3 网址之后一部分，或者没有网址的方式 (https://rubular.com/r/sXLihPuKPpJrCI)
/(^.*\/|^)(.*)$/
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;/ul>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://www.cnblogs.com/flyor/p/6411140.html" rel="noopener" target="_blank">linux中grep命令的用法&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://blog.csdn.net/yufenghyc/article/details/51078107" rel="noopener" target="_blank">grep中使用&amp;quot;\d&amp;quot;匹配数字不成功的原因解决&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://blog.csdn.net/csm0912/article/details/81206848" rel="noopener" target="_blank">(?:)&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/awk/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/awk/</guid><description>&lt;p class="tip">awk (Alfred Aho 、Peter Weinberger 和 Brian Kernighan):
&lt;br /> 样式扫描和处理语言，它允许您创建简短的程序。读取输入文件，为数据排序，处理数据，对输入执行计算以及生成报表等。其中语法方面有借鉴C语言。&lt;/p>
&lt;h2 id="一语法格式">
 一.语法格式：
 &lt;a class="anchor" href="#%e4%b8%80%e8%af%ad%e6%b3%95%e6%a0%bc%e5%bc%8f">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">awk 'pattern{action[;action..]}' {filenames}
 
原理：
 调用awk时，依次对文件中匹配的每一行做后面的action，每一对pattern+action用分号[;]隔开。
注意：
 如果一个'' 中没有pattern，默认所有行。action 必须{}包起来
 如果一个'' 中没有action，默认打印本行。
 如果什么都没有，只有'',不做任何处理。
 print,printf:
 print 输出后加一个ORS，而printf标准输出，想换行得加'\n',而这个换行不受awk的ORS控制。
&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="二常用选项">
 二.常用选项：
 &lt;a class="anchor" href="#%e4%ba%8c%e5%b8%b8%e7%94%a8%e9%80%89%e9%a1%b9">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">[option]
 -F fs or --field-separator fs :指定输入文件拆分符，是一个字符串或正则，如-F:
 -v var=value or --asign var=value :赋值一个用户变量
 -f scripfile or --file scriptfile :从脚本文件中读取awk命令。
 -mf nnn and -mr nnn :对nnn值设置内在限制，-mf选项限制分配给nnn的最大块数目；-mr选项限制记录的最大数目。这两个功能是Bell实验室版awk的扩展功能，在标准awk中不适用。
 -W compact or --compat, -W traditional or --traditional :在兼容模式下运行awk。所以gawk的行为和标准的awk完全一样，所有的awk扩展都被忽略。
 -W copyleft or --copyleft, -W copyright or --copyright :打印简短的版权信息。
 -W help or --help, -W usage or --usage :打印全部awk选项和每个选项的简短说明。
 -W lint or --lint :打印不能向传统unix平台移植的结构的警告。
 -W lint-old or --lint-old :打印关于不能向传统unix平台移植的结构的警告。
 -W posix :打开兼容模式。但有以下限制，不识别：/x、函数关键字、func、换码序列以及当fs是一个空格时，将新行作为一个域分隔符；操作符**和**=不能代替^和^=；fflush无效。
 -W re-interval or --re-inerval :允许间隔正则表达式的使用，参考(grep中的Posix字符类)，如括号表达式[[:alpha:]]。
 -W source program-text or --source program-text :使用program-text作为源代码，可与-f命令混用。
 -W version or --version :打印bug报告信息的版本。
&lt;/code>&lt;/pre>&lt;/div>
&lt;ul>
&lt;li>
&lt;h2 id="三-使用案例">
 三. 使用案例：
 &lt;a class="anchor" href="#%e4%b8%89-%e4%bd%bf%e7%94%a8%e6%a1%88%e4%be%8b">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="1简单样例">
 1）简单样例
 &lt;a class="anchor" href="#1%e7%ae%80%e5%8d%95%e6%a0%b7%e4%be%8b">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># echo 'hello this' | awk '' &amp;gt; 默认不做处理
# echo 'hello this' | awk '/hello/' &amp;gt;打印hello this
# echo 'hello this' | awk '{print $0}' &amp;gt;打印hello this

# cat test.txt | awk '{if(NR&amp;gt;=20 &amp;amp;&amp;amp; NR&amp;lt;=30) print $0}' &amp;gt; 打印20～30行内容

&amp;gt;test.txt
I am Poe,my qq is 1234567
# cat test.txt | awk -F '[ ,]+' '{print $3&amp;quot; &amp;quot;$7' &amp;gt;Poe 1234567
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="2beginend模块">
 2）BEGIN，END模块
 &lt;a class="anchor" href="#2beginend%e6%a8%a1%e5%9d%97">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># cat /etc/passwd | awk '{count++;print $0;}END{print &amp;quot;count is&amp;quot;,count}' &amp;gt;统计/etc/passwd的账户人数
# ll | awk '{size=size+$5}END{print &amp;quot;size is&amp;quot;,size/1024,&amp;quot;K&amp;quot;}' &amp;gt;统计某个文件夹下总字节数
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="3awk运算符">
 3）awk运算符
 &lt;a class="anchor" href="#3awk%e8%bf%90%e7%ae%97%e7%ac%a6">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># awk 'BEGIN{a=5;a+=5;print a}' &amp;gt;5,赋值运算符
# awk 'BEGIN{a=1;b=2;print (a&amp;gt;2&amp;amp;&amp;amp;b&amp;gt;1,a=1||b&amp;gt;1)}' &amp;gt;0 1 ,逻辑运算符
# awk 'BEGIN{a=&amp;quot;100testaa&amp;quot;;if(a~/100/)print &amp;quot;OK&amp;quot;}' &amp;gt;OK,正则运算符
# awk 'BEGIN{a=&amp;quot;100testaa&amp;quot;} a~/100/ {print &amp;quot;OK&amp;quot;}' &amp;gt;等待用户输入
# awk 'BEGIN{a=&amp;quot;11&amp;quot;;if(a&amp;gt;=9){print &amp;quot;ok&amp;quot;}}' &amp;gt;无输出,关系运算符
# awk 'BEGIN{a=11;if(a&amp;gt;=9){print &amp;quot;ok&amp;quot;}}' &amp;gt;ok
# awk 'BEGIN{a;if(a&amp;gt;=b){print &amp;quot;ok&amp;quot;}}' &amp;gt;ok
# awk 'BEGIN{a=&amp;quot;b&amp;quot;;print a++,++a}' &amp;gt;0 2,算数运算符
# awk 'BEGIN{a=&amp;quot;20b4&amp;quot;;print a++,++a}' &amp;gt;20 22
# awk 'BEGIN{a=&amp;quot;b&amp;quot;;print a==&amp;quot;b&amp;quot;?&amp;quot;ok&amp;quot;:&amp;quot;err&amp;quot;}' &amp;gt;ok,三目运算符
# awk 'BEGIN{a=&amp;quot;b&amp;quot;;print a==&amp;quot;c&amp;quot;?&amp;quot;ok&amp;quot;:&amp;quot;err&amp;quot;}' &amp;gt;err
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="4常用awk内置变量">
 4）常用awk内置变量
 &lt;a class="anchor" href="#4%e5%b8%b8%e7%94%a8awk%e5%86%85%e7%bd%ae%e5%8f%98%e9%87%8f">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">$0 当前记录
$1~$n 当前记录的第n个字段
FS 输入字段分隔符，默认空格
RS 输入记录分隔符，默认换行符
NF 当前记录书中的字段个数
NR 行号，从1开始
OFS 输出字段分隔符，默认空格
ORS 输出记录分隔符，默认换行符

&amp;gt;tab.txt
ww CC IDD

# cat tab.txt | awk 'BEGIN{FS=&amp;quot;\t+&amp;quot;}{print $1,$2,$3}' &amp;gt;ww CC IDD
# cat space.txt | awk -F [[:space:]+] '{print $1,$2,$3,$4,$5}'
# cat hello.txt | awk -F [&amp;quot; &amp;quot;:]+ '{print $1,$2,$3}'
# cat hello.txt | awk -F &amp;quot;:&amp;quot; 'NF==8{print $0}' hello.txt
# ifconfig eth0 | awk -F [&amp;quot; &amp;quot;:]+ 'NR==2{print $4}'

&amp;gt;record.txt
Jimmy the Weasel
100 Pleasant Drive
San Francisco,CA 123456

Big Tony
200 Incognito Ave.
Suburbia,WA 64890

&amp;gt;awk.txt
#!/bin/awk
BEGIN {
 FS=&amp;quot;\n&amp;quot;
 RS=&amp;quot;&amp;quot;
}
{
 print $1&amp;quot;,&amp;quot;$2&amp;quot;,&amp;quot;$3
}

# awk -f awk.txt recode.txt 
&amp;gt;Jimmy the Weasel,100 Pleasant Drive,San Francisco,CA 123456
&amp;gt;Big Tony,200 Incognito Ave.,Suburbia,WA 64890
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="5awk正则">
 5）awk正则
 &lt;a class="anchor" href="#5awk%e6%ad%a3%e5%88%99">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># cat /etc/passwd | awk '/root/{print $0}'
# cat /etc/passwd | awk -F: '$5~/root/{print $0}'
# cat /etc/passwd | awk -F: '$1==&amp;quot;root&amp;quot;{print $0}'
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="6awk的c语言特性if循环和数组">
 6）awk的C语言特性（if,循环和数组）
 &lt;a class="anchor" href="#6awk%e7%9a%84c%e8%af%ad%e8%a8%80%e7%89%b9%e6%80%a7if%e5%be%aa%e7%8e%af%e5%92%8c%e6%95%b0%e7%bb%84">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">-----------------------------
{
 if(){
 if(){
 ...
 }else{
 ...
 }
 }elseif(){
 ...
 }else{
 ...
 }
}
-----------------------------
{
 count=1 do{
 ...
 if(){
 break;
 }
 } while()
}
-----------------------------
for(x=1;x&amp;lt;=4;x++){
 ...
 if(){
 continue;
 }
}
-----------------------------
awk中的数组是关联数组，数字索引也会转变为字符串索引，是无序的，有序的得通过下标获得
-----------------------------
{
 cities[1]=&amp;quot;beijing&amp;quot;
 cities[2]=&amp;quot;shanghai&amp;quot;
 cities[“three”]=&amp;quot;guangzhou&amp;quot;
 for( c in cities){
 print cities[c]
 }
 print cities[&amp;quot;three&amp;quot;]; //也可以
}
# netstat -an|awk '/^tcp/{++s[$NF]}END{for(a in s)print a,s[a]}' 
&amp;gt;LISTEN 9
&amp;gt;ESTABLISHED 4
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="7常用字符串函数">
 7）常用字符串函数
 &lt;a class="anchor" href="#7%e5%b8%b8%e7%94%a8%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">#替换
# awk 'BEGIN{info=&amp;quot;this is a test2010test!&amp;quot;;gsub(/[0-9]+/,&amp;quot;!&amp;quot;,info);print info}' &amp;gt;this is a test!test!

#查找
# awk 'BEGIN{info=&amp;quot;this is a test2010test!&amp;quot;;print index(info,&amp;quot;test&amp;quot;)?&amp;quot;ok&amp;quot;:&amp;quot;no found&amp;quot;;}' &amp;gt;ok

#匹配查找
# awk 'BEGIN{info=&amp;quot;this is a test2010test!&amp;quot;;print match(info,/[0-9]+/)?&amp;quot;ok&amp;quot;:&amp;quot;no found&amp;quot;;}' &amp;gt;ok

#截取
# awk 'BEGIN{info=&amp;quot;this is a test2010test!&amp;quot;;print substr(info,4,10);}' &amp;gt;s is a tes

#分割
# awk 'BEGIN{info=&amp;quot;this is a test&amp;quot;;split(info,tA,&amp;quot; &amp;quot;);print length(tA);for(k in tA){print k,tA[k];}}'
&amp;gt;4
&amp;gt;4 test
&amp;gt;1 this
&amp;gt;2 is
&amp;gt;3 a

#length(),blength(),tolower(),toupper()...等
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="四参考">
 四.参考：
 &lt;a class="anchor" href="#%e5%9b%9b%e5%8f%82%e8%80%83">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://www.cnblogs.com/ginvip/p/6352157.html" rel="noopener" target="_blank"> Linux三剑客之awk命令 &lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://www.runoob.com/linux/linux-comm-awk.html" rel="noopener" target="_blank"> Linux awk 命令 &lt;/a>&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/sed/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/sed/</guid><description>&lt;h2 id="sed-stream-editor">
 sed (Stream Editor):
 &lt;a class="anchor" href="#sed-stream-editor">#&lt;/a>
&lt;/h2>
&lt;p class="tip">文本流编辑，是一个&amp;quot;非交互式的&amp;quot;面向字符流的编辑器。能同时处理多个文件多行内容，可以不对源文件改动，把整个文件输入到屏幕，可以把只匹配到模式的内容输出到屏幕上。还可以对源文件改动，但是不会在屏幕上返回结果。&lt;/p>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">[root@12302 ~]# sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: &amp;lt;http://www.gnu.org/software/sed/&amp;gt;.
General help using GNU software: &amp;lt;http://www.gnu.org/gethelp/&amp;gt;.
E-mail bug reports to: &amp;lt;bug-sed@gnu.org&amp;gt;.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
&lt;/code>&lt;/pre>&lt;/div>
&lt;h3 id="一语法格式">
 一.语法格式：
 &lt;a class="anchor" href="#%e4%b8%80%e8%af%ad%e6%b3%95%e6%a0%bc%e5%bc%8f">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># If no -e, --expression, -f, or --file option is given, then the first non-option argument is taken as the sed script to interpret. 
# All remaining arguments are names of input files; if no input files are specified, then the standard input is read.
sed [OPTION]... {script-only-if-no-other-script} [input-file]...
&lt;/code>&lt;/pre>&lt;/div>
&lt;h3 id="二常用选项">
 二.常用选项：
 &lt;a class="anchor" href="#%e4%ba%8c%e5%b8%b8%e7%94%a8%e9%80%89%e9%a1%b9">#&lt;/a>
&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>option&lt;/th>
&lt;th>describe&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>-n, &amp;ndash;quiet, &amp;ndash;silent&lt;/td>
&lt;td>suppress automatic printing of pattern space&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-e script, &amp;ndash;expression=script&lt;/td>
&lt;td>add the script to the commands to be executed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-r, &amp;ndash;regexp-extended&lt;/td>
&lt;td>use extended regular expressions in the script.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-f script-file, &amp;ndash;file=script-file&lt;/td>
&lt;td>add the contents of script-file to the commands to be executed&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;ndash;follow-symlinks&lt;/td>
&lt;td>follow symlinks when processing in place&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-i[SUFFIX], &amp;ndash;in-place[=SUFFIX]&lt;/td>
&lt;td>edit files in place (makes backup if SUFFIX supplied)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-c, &amp;ndash;copy&lt;/td>
&lt;td>use copy instead of rename when shuffling files in -i mode&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-s, &amp;ndash;separate&lt;/td>
&lt;td>consider files as separate rather than as a single continuous long stream.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-z, &amp;ndash;null-data&lt;/td>
&lt;td>separate lines by NUL characters&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;ndash;version&lt;/td>
&lt;td>output version information and exit&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;hellip;&lt;/td>
&lt;td>&amp;hellip;&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="三地址匹配">
 三.地址匹配：
 &lt;a class="anchor" href="#%e4%b8%89%e5%9c%b0%e5%9d%80%e5%8c%b9%e9%85%8d">#&lt;/a>
&lt;/h3>
&lt;p class="warn">Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. Three things to note about address
ranges: the syntax is addr1,addr2 (i.e., the addresses are separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against the line that addr1 matched.
&lt;br>&lt;strong>After the address (or address-range), and before the command, a ! may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match.&lt;/strong>&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/curl/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/curl/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introcurl-client-url">
 Intro(CURL| client url)
 &lt;a class="anchor" href="#introcurl-client-url">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="syntax">
 SYNTAX
 &lt;a class="anchor" href="#syntax">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># 1、直接访问默认是get
curl http://www.example.com 
# 2、-i,--include 打印响应头
curl http://www.example.com -i 
# 3、-I,--head 大写的只会打印响应头信息
curl http://www.example.com -I
# 3、-v,--verbose 详细信息
curl http://www.example.com -v
# 4、-d,--date 请求数据 配合-X(请求方式)
curl http://www.example.com -X post -d &amp;quot;username=xhsgg&amp;amp;pwd=123456&amp;quot;
# 5、-b,--cookie 附带cookie信息
curl http://www.example.com -b &amp;quot;JSESSIONID=************;time=***&amp;quot;
# 6、-H,--header 请求头消息，可以携带多个请求头
curl http://www.example.com -H &amp;quot;Content-Type:application/json&amp;quot;
# 7、-F,--form 表单的内容，可以上传文件
curl http://www.example.com -F &amp;quot;file=@_path_&amp;quot;

# 8、-L,--location 参数会让 http 请求跟随服务器的重定向，默认不跟随。
curl -L -i http://www.wtfu.site

# 9、-k,参数跳过 ssl/tls 证书检测
curl -k https://www.example.com

# 10、-x, 指定请求代理
curl -x socks5h://127.0.0.1:7890 https://yifen.996.buzz/gengxin
curl -x socks://127.0.0.1:7890 https://wtfu.site
curl -x 127.0.0.1:7890 https://yifen.996.buzz/gengxin
curl -x http://127.0.0.1:7890 https://webget.yfjc.xyz/api/v1/client/subscribe
curl -x https://127.0.0.1:10126 https://music.163.com/\#/song\?id\=1397021895
curl -x https://127.0.0.1:7890 -I https://wtfu.site

# 11、-X, 指定请求方法
curl -X POST https://www.example.com

# 12、-o,-O 保存文件
curl -o example.html https://www.example.com ==&amp;gt; example.html
curl -O https://www.example.com/foo/bar.html ==&amp;gt; bar.html

# 13 -T,--upload-file &amp;lt;file&amp;gt;
gpg --export 425B8CB8073AAC1EB005E4E648E1F1185160B400 | curl -T - https://keys.openpgp.org

# 使用curl 实现 telnet .追加超时时间是因为，有的服务器有安全策略阻止，会一直等待链接超时，效果跟端口开放相差无几，造成误解。
curl --connect-timeout 1 telnet://wtfu.site:30000
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="样例">
 样例
 &lt;a class="anchor" href="#%e6%a0%b7%e4%be%8b">#&lt;/a>
&lt;/h3>
&lt;ul>
&lt;li>
&lt;h4 id="1ajax提交new-from">
 1.ajax提交new from
 &lt;a class="anchor" href="#1ajax%e6%8f%90%e4%ba%a4new-from">#&lt;/a>
&lt;/h4>
&lt;p>&lt;img src="https://archive-w.netlify.app/.images/devops/os/util/curl-first.png" alt="" width="100%">&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/wget/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/wget/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introwget">
 Intro(wget)
 &lt;a class="anchor" href="#introwget">#&lt;/a>
&lt;/h2>
&lt;h3 id="响应内容到标准输出">
 响应内容到标准输出
 &lt;a class="anchor" href="#%e5%93%8d%e5%ba%94%e5%86%85%e5%ae%b9%e5%88%b0%e6%a0%87%e5%87%86%e8%be%93%e5%87%ba">#&lt;/a>
&lt;/h3>
&lt;p class="warn">&lt;code>wget -q -O - -A 'Accept: application/xml' http://localhost:8080/test/helloxml&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://blog.csdn.net/geekooler/article/details/100853072" rel="noopener" target="_blank">https://blog.csdn.net/geekooler/article/details/100853072&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/adb/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/adb/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introadb">
 Intro(ADB)
 &lt;a class="anchor" href="#introadb">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="push">
 PUSH
 &lt;a class="anchor" href="#push">#&lt;/a>
&lt;/h3>
&lt;p class="warn">push moive to android:
&lt;br>&lt;code>adb push /path/FILENAME.mp4 /sdcard/&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;h3 id="systempropgetprop">
 SYSTEMPROP(getprop)
 &lt;a class="anchor" href="#systempropgetprop">#&lt;/a>
&lt;/h3>
&lt;p class="warn">通过


 &lt;a href="https://github.com/topjohnwu/Magisk/blob/master/docs/guides.md#the-system-folder" rel="noopener" target="_blank">magisk设置系统属性&lt;/a>，然后根据


 &lt;a href="https://xdaforums.com/t/how-to-make-adb-listen-to-tcpip-5555-after-reboot.1825359/#post-30032364" rel="noopener" target="_blank">文章&lt;/a>操作：&lt;code>setprop service.adb.tcp.port 5555&lt;/code>:可以让手机中的adbd开放指定的tcp端口，方便连接调试。&lt;/p>
&lt;div class="alert callout attention">&lt;p class="title">&lt;span class="icon icon icon-attention">&lt;/span> Caution &lt;/p>&lt;p> &lt;code>1).&lt;/code> &lt;span style='color:blue'>一直开放tcp端口也有分险，需要注意。&lt;/span>
&lt;br>&lt;code>2).&lt;/code> 直接在&lt;code>/system/build.prop&lt;/code>文件中编辑不生效(如果对/system分区没有写权限的话)。需要借助 &lt;strong>magisk&lt;/strong> 模块中的&lt;code>system.prop&lt;/code>。&lt;/p>
&lt;/p>&lt;/div>
&lt;p>&lt;img src="https://archive-w.netlify.app/.images/devops/os/util/adb-prop-01.png" alt="" width="48%">
&lt;img src="https://archive-w.netlify.app/.images/devops/os/util/adb-prop-02.png" alt="" width="49%">&lt;/p>
&lt;/li>
&lt;li>
&lt;h3 id="adb添加系统证书的方法">
 ADB添加系统证书的方法
 &lt;a class="anchor" href="#adb%e6%b7%bb%e5%8a%a0%e7%b3%bb%e7%bb%9f%e8%af%81%e4%b9%a6%e7%9a%84%e6%96%b9%e6%b3%95">#&lt;/a>
&lt;/h3>
&lt;p class="warn">【


 
 

 
 
 
 
 
 
 
 &lt;a href='../openssl/#adb-%e6%b7%bb%e5%8a%a0%e7%b3%bb%e7%bb%9f%e8%af%81%e4%b9%a6%e6%96%b9%e6%b3%95' rel="noopener" class="internal-link" data-src="../openssl/#adb-%e6%b7%bb%e5%8a%a0%e7%b3%bb%e7%bb%9f%e8%af%81%e4%b9%a6%e6%96%b9%e6%b3%95">Docs|参见&lt;/a>】&lt;/p>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://github.com/12302-bak/awesome-adb" rel="noopener" target="_blank">https://github.com/12302-bak/awesome-adb&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://forum.xda-developers.com/t/a-magisk-script-to-set-adb-tcpip-port-at-startup-without-bricking-my-phone.4533603/" rel="noopener" target="_blank">https://forum.xda-developers.com/t/a-magisk-script-to-set-adb-tcpip-port-at-startup-without-bricking-my-phone.4533603/&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://github.com/12302-bak/awesome-adb?tab=readme-ov-file#%E6%97%A0%E7%BA%BF%E8%BF%9E%E6%8E%A5%E6%97%A0%E9%9C%80%E5%80%9F%E5%8A%A9-usb-%E7%BA%BF" rel="noopener" target="_blank">https://github.com/12302-bak/awesome-adb?tab=readme-ov-file#%E6%97%A0%E7%BA%BF%E8%BF%9E%E6%8E%A5%E6%97%A0%E9%9C%80%E5%80%9F%E5%8A%A9-usb-%E7%BA%BF&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://xdaforums.com/t/how-to-make-adb-listen-to-tcpip-5555-after-reboot.1825359/#post-30032364" rel="noopener" target="_blank">https://xdaforums.com/t/how-to-make-adb-listen-to-tcpip-5555-after-reboot.1825359/#post-30032364&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://github.com/topjohnwu/Magisk/blob/master/docs/guides.md#the-system-folder" rel="noopener" target="_blank">https://github.com/topjohnwu/Magisk/blob/master/docs/guides.md#the-system-folder&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/bc/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/bc/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introbc--basic-calculator">
 Intro(BC | basic calculator)
 &lt;a class="anchor" href="#introbc--basic-calculator">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="保留位数">
 保留位数
 &lt;a class="anchor" href="#%e4%bf%9d%e7%95%99%e4%bd%8d%e6%95%b0">#&lt;/a>
&lt;/h3>
&lt;p class="warn">&lt;code>echo 'scale=3; 10 / 3' | bc &lt;/code>
&lt;br>&lt;code>echo 'scale=5; 820 / (480 + 90)' | bc&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;h3 id="指数对数-计算">
 指数/对数 计算
 &lt;a class="anchor" href="#%e6%8c%87%e6%95%b0%e5%af%b9%e6%95%b0-%e8%ae%a1%e7%ae%97">#&lt;/a>
&lt;/h3>
&lt;div class="alert callout note">&lt;p class="title">&lt;span class="icon icon-note">&lt;/span> Note &lt;/p>&lt;p> &lt;code>echo '2 ^ 3' | bc&lt;/code>
&lt;br>&lt;code>echo 'log(8,2)' | bc -l&lt;/code>&lt;/p>
&lt;/p>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="异或">
 异或
 &lt;a class="anchor" href="#%e5%bc%82%e6%88%96">#&lt;/a>
&lt;/h3>
&lt;p class="warn">&lt;code>echo 'ibase=16;obase=10;bxor(1,2)' | bc -l&lt;/code> ==&amp;gt; 3&lt;/p>
&lt;/li>
&lt;li>
&lt;h3 id="进制转换">
 进制转换
 &lt;a class="anchor" href="#%e8%bf%9b%e5%88%b6%e8%bd%ac%e6%8d%a2">#&lt;/a>
&lt;/h3>
&lt;div class="alert callout attention">&lt;p class="title">&lt;span class="icon icon icon-attention">&lt;/span> Caution &lt;/p>&lt;p> &lt;code>1).&lt;/code>: 特别需要注意 ibase，obase，以及值之间的联系，不然会出现意想不到的结果。如下图：


 &lt;a href="https://unix.stackexchange.com/questions/199615/understand-ibase-and-obase-in-case-of-conversions-with-bc" rel="noopener" target="_blank">参见&lt;/a>
&lt;br>简而言之，就是在进制转换的时候，不管&lt;code>ibase&lt;/code>、&lt;code>obase&lt;/code>哪一个在前，都要以前面使用的进制为主，对后面的值以前面的进制进行转换。举例如下：
&lt;br>在2到八进制中，可以写成&lt;code>ibase=2;obase=1000;&lt;/code>，或者&lt;code>obase=8;ibase=2;&lt;/code>，对于第一个，（2，1000），1000 为二进制的值 8，第二个（8，2），2 为八进制中的值 2
&lt;br>&lt;br>&lt;code>2).&lt;/code>: 十六进制中的字母需要大写。小写就是: &lt;strong>(standard_in) 1: syntax error&lt;/strong>。&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/find/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/find/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introfind">
 Intro(find)
 &lt;a class="anchor" href="#introfind">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="syntax">
 syntax
 &lt;a class="anchor" href="#syntax">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># 1，在home目录下查找txt 结尾或者 sh 结尾的文件
find /home -name &amp;quot;*.txt&amp;quot; -o -name &amp;quot;*.sh&amp;quot;
# 2，查找路径，文件名中包含 lib 的文件
find /home -path &amp;quot;*lib*&amp;quot;
# 3，表达式匹配
find /home -regex &amp;quot;.*(\.txt | \.sh)$&amp;quot;
# 4，否定参数
find /home ! -name &amp;quot;*.txt&amp;quot;
# 5，文件类型
find /home -type [f普通文件 | l符号连接 | d 目录 | c 字符设备| b块设备 | s套接字 | p Fifo]
# 6，目录深度搜索
find /home -maxdepth 3
# 7，文件大小
find /home -size [+10k | -10k | 10K]
# 8，过滤权限拒绝的文件
find /home [-perm 777 | -user tom | -group git]
# 9，exec | ok
find /home -size 10k -[exec | ok] ls -l {} \; 
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;li>
&lt;h3 id="样例">
 样例
 &lt;a class="anchor" href="#%e6%a0%b7%e4%be%8b">#&lt;/a>
&lt;/h3>
&lt;ol>
&lt;li>
&lt;p>&lt;code>find / -name &amp;quot;*.jar&amp;quot; -a -path &amp;quot;*jetbrains*&amp;quot; 2&amp;gt;/dev/null &lt;/code>&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/firewalld/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/firewalld/</guid><description>&lt;h1 id="linux-防火墙">
 Linux 防火墙
 &lt;a class="anchor" href="#linux-%e9%98%b2%e7%81%ab%e5%a2%99">#&lt;/a>
&lt;/h1>
&lt;h2 id="iptables-services">
 iptables-services
 &lt;a class="anchor" href="#iptables-services">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="服务操作">
 服务操作
 &lt;a class="anchor" href="#%e6%9c%8d%e5%8a%a1%e6%93%8d%e4%bd%9c">#&lt;/a>
&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>index&lt;/th>
&lt;th>content&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>安装&lt;/td>
&lt;td>&lt;code>yum install iptables-services&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>配置&lt;/td>
&lt;td>&lt;code>vim /etc/sysconfig/iptables&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>永久保存&lt;/td>
&lt;td>&lt;code>service iptables save&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>状态&lt;/td>
&lt;td>&lt;code>systemctl status iptables&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>启动&lt;/td>
&lt;td>&lt;code>systemctl status start&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>停止&lt;/td>
&lt;td>&lt;code>systemctl status stop&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>重启&lt;/td>
&lt;td>&lt;code>systemctl status restart&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>关闭自启服务&lt;/td>
&lt;td>&lt;code>chkconfig iptables off&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>开启自启服务&lt;/td>
&lt;td>&lt;code>chkconfig iptables on&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/li>
&lt;li>
&lt;h3 id="格式--t没有-默认filter">
 格式 （-t没有 默认filter）
 &lt;a class="anchor" href="#%e6%a0%bc%e5%bc%8f--t%e6%b2%a1%e6%9c%89-%e9%bb%98%e8%ae%a4filter">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;/ul>
&lt;p class="tip">iptables [-t 表名] 操作选项 [链名] [条件] [-j 控制类型]&lt;/p>
&lt;ul>
&lt;li>
&lt;h3 id="样例">
 样例
 &lt;a class="anchor" href="#%e6%a0%b7%e4%be%8b">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># 地址转发与伪装:
# 先进行如下的配置
# 1.1.1.200 1.1.1.100(eth1) 172.25.254.72
# server虚拟机 172.25.254.233(eth0) 真机
# desktop虚拟机 
# 源地址地址转发（SNAT）：伪装
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 172.25.254.233

# 目的地地址转发（DNAT）：转发
# desktop中设置:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -j DNAT --to-dest 1.1.1.200:22
&lt;/code>&lt;/pre>&lt;/div>
&lt;ul>
&lt;li>&lt;code>iptables -X -F -Z&lt;/code> &lt;code>：重置防火墙&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -nL INPUT&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -P INPUT DROP&lt;/code> &lt;code>：修改INPUT链默认策略，默认所有链都是[ACCEPT]&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -t filter -I INPUT -p tcp --dport 80 -j DROP&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -D INPUT -p tcp --dport 80 -j DROP&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -D INPUT -p tcp -s 42.89.72.49 --dport 80 -j REJECT&lt;/code>&lt;/li>
&lt;li>&lt;code>cat blacklist.ip | xargs -I % sudo iptables -t filter -A INPUT -s % -j DROP&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEP&lt;/code>&lt;/li>
&lt;li>&lt;code> iptables -I INPUT -i eth0 -p tcp --tcp-flags SYN,RST,ACK SYN -j DROP&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -t filter -A INPUT -p icmp -j REJECT&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -I INPUT -p icmp --icmp-type 8 -j DROP&lt;/code> &lt;code>:我们可以ping别人,但是别人不能ping我们,[OUTPUT|0]相反&lt;/code>&lt;/li>
&lt;li>&lt;code>iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o ens33 -j SNAT --to-source 192.168.200.10&lt;/code>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;h3 id="注意事项">
 注意事项
 &lt;a class="anchor" href="#%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9">#&lt;/a>
&lt;/h3>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">1. iptables可以使用扩展bai模块来进行数据包du的匹配，zhi语法就是 -m modaole_name, 所以
-m tcp 的意思是使用zhuan tcp 扩展模块shu的功能 (tcp扩展模块提供权了 --dport, --tcp-flags, --sync等功能）
其实只用 -p tcp 了话， iptables也会默认的使用 -m tcp 来调用 tcp模块提供的功能。
但是 -p tcp 和 -m tcp是两个不同层面的东西，一个是说当前规则作用于 tcp 协议包，而后一是说明要使用iptables的tcp模块的功能 (--dport 等)

1. DROP,REJECT 第一个直接丢弃，需要等待客户端链接超时，而REJECT会返回一个关闭连接信息。响应快点。

2. 使用nat 时注意修改内核参数 `echo &amp;quot;net.ipv4.ip_forward=1&amp;quot; &amp;gt;&amp;gt; /usr/lib/sysctl.d/50-default.conf`(重启) 
或者直接 `echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward` 使用`sysctl -a | grep ip_forward` 查看修改后的属性
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;/ul>
&lt;h2 id="firewalld">
 firewalld
 &lt;a class="anchor" href="#firewalld">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="omitted">
 OMITTED
 &lt;a class="anchor" href="#omitted">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;/ul>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://blog.csdn.net/ly2020_/article/details/90747911" rel="noopener" target="_blank">linux中的防火墙的基本设置&amp;mdash;firewlld、iptables&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/GnuPG/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/GnuPG/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="intrognupg">
 Intro(GnuPG)
 &lt;a class="anchor" href="#intrognupg">#&lt;/a>
&lt;/h2>
&lt;p style="text-align: center;">&lt;img src="https://archive-w.netlify.app/.images/devops/os/util/gpg-intro-01.png" alt="" width="70%" title="https">&lt;/p>
&lt;ul>
&lt;li>
&lt;h3 id="基本概念">
 基本概念
 &lt;a class="anchor" href="#%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5">#&lt;/a>
&lt;/h3>
&lt;div class="alert flat tip">&lt;p class="title">&lt;span class="icon icon-tip">&lt;/span> Tip &lt;/p>&lt;p>
Key 管理是 GPG 的核心功能，GPG Key 不能简单的理解为非对称加密的 Private Key / Public Key / Key Pair。GPG Key 由如下信息组成：
&lt;br>&lt;br>Key ID: 该 GPG Key 的唯一标识，值为主公钥的指纹，支持多种格式(Fingerprint, Long key ID, Short key ID)，更多参见：What is a OpenPGP/GnuPG key ID?。
&lt;br>UID: 1 个或多个，每个 UID 由 name、email、comment 组成，email 和 comment 可以为空。
&lt;br>Expire: 过期时间，可以为永久。
&lt;br>多个具有不同用途的非对称加密算法中的 Key 的集合。&lt;/p>
&lt;/p>&lt;/div> &lt;div class="docsify-example-panels"> &lt;div class="docsify-example-panel left-panel"style="max-width: 50%; width: 50%;">
&lt;div class="alert callout warning">&lt;p class="title">&lt;span class="icon icon-warning">&lt;/span> key 分类参见下表 &lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/hashcat/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/hashcat/</guid><description>&lt;h1 id="hashcat-简单使用">
 hashcat 简单使用
 &lt;a class="anchor" href="#hashcat-%e7%ae%80%e5%8d%95%e4%bd%bf%e7%94%a8">#&lt;/a>
&lt;/h1>
&lt;p class="tip">


 &lt;a href="https://github.com/hashcat/hashcat.git" rel="noopener" target="_blank">https://github.com/hashcat/hashcat.git&lt;/a>&lt;/p>
&lt;ul>
&lt;li>
&lt;h2 id="rar-crack">
 rar crack
 &lt;a class="anchor" href="#rar-crack">#&lt;/a>
&lt;/h2>
&lt;/li>
&lt;/ul>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell"># 提取hash值，注意裁剪文件名
rar2john 9.rar &amp;gt; example0.hash
# output:
# $rar5$16$8345875512857bc69f0a8059ffce0166$15$7880153df518399181c9e2df158b7249$8$f627000464e14963
# 使用hashcat撞库
hashcat -a 3 -m 13000 -O -1 '?d?l' -D 1,2 -d 3,5 example0.hash '?l?l?l123'
# 自定义字符集
hashcat -a 3 -m 13000 -1 '?d?l' -D 1,2 -d 3,5 example0.hash '?1?1?1?1?1?1'
# hashcat.potfile
# /Users/stevenobelia/.local/share/hashcat/hashcat.potfile
# 查看破解记录
hashcat --show example0.hash
&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="注意">
 注意：
 &lt;a class="anchor" href="#%e6%b3%a8%e6%84%8f">#&lt;/a>
&lt;/h2>
&lt;blockquote>
&lt;p>安装john-ripper后需要链接rar2john



 &lt;a href="https://superuser.com/questions/1652553/john-the-ripper-zip2john-command-not-found-mac/1670026" rel="noopener" target="_blank">https://superuser.com/questions/1652553/john-the-ripper-zip2john-command-not-found-mac/1670026&lt;/a>
创建软链&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/keytool/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/keytool/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introkeytool--java--平台证书工具">
 Intro(keytool | Java 平台证书工具)
 &lt;a class="anchor" href="#introkeytool--java--%e5%b9%b3%e5%8f%b0%e8%af%81%e4%b9%a6%e5%b7%a5%e5%85%b7">#&lt;/a>
&lt;/h2>
&lt;/li>
&lt;li>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/nmap/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/nmap/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="intronmap--参考指南">
 Intro(Nmap | 参考指南)
 &lt;a class="anchor" href="#intronmap--%e5%8f%82%e8%80%83%e6%8c%87%e5%8d%97">#&lt;/a>
&lt;/h2>
&lt;p class="warn">


 &lt;a href="https://nmap.org/man/zh/index.html#:~:text=是一款,服务的运行。" rel="noopener" target="_blank">拿来主义&lt;/a>：Nmap (“Network Mapper(网络映射器)”) 是一款开放源代码的 网络探测和安全审核的工具。它的设计目标是快速地扫描大型网络，当然用它扫描单个主机也没有问题。Nmap以新颖的方式使用原始IP报文来发现网络上有哪些主机，那些 主机提供什么服务(应用程序名和版本)，那些服务运行在什么操作系统(包括版本信息)， 它们使用什么类型的报文过滤器/防火墙，以及一堆其它功能。虽然Nmap通常用于安全审核， 许多系统管理员和网络管理员也用它来做一些日常的工作，比如查看整个网络的信息， 管理服务升级计划，以及监视主机和服务的运行。
&lt;br>&lt;br>example:
&lt;br>&lt;code>nmap -v -A scanme.nmap.org&lt;/code>
&lt;br>&lt;code>nmap -v -sP 192.168.0.0/16 10.0.0.0/8&lt;/code>
&lt;br>&lt;code>nmap -v -iR 10000 -P0 -p 80&lt;/code>&lt;/p>
&lt;ul>
&lt;li>
&lt;h3 id="端口状态">
 端口状态
 &lt;a class="anchor" href="#%e7%ab%af%e5%8f%a3%e7%8a%b6%e6%80%81">#&lt;/a>
&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>state&lt;/th>
&lt;th>explain&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>open&lt;/td>
&lt;td>意味着目标机器上的应用程序正在该端口监听连接/报文&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>close&lt;/td>
&lt;td>端口没有应用程序在它上面监听&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>filtered&lt;/td>
&lt;td>意味着防火墙，过滤器或者其它网络障碍阻止了该端口被访问 &lt;br> open/close | filtered :有可能开放/关闭 或者被过滤，拦截等。&lt;br>比如对于&lt;code>open | filtered&lt;/code>来说，如果发送的报文有返回的时候认为是 close 的，那没返回的话就无法确定到底是被过滤了，还是真的 open。也既文档中的 


 &lt;a href="https://nmap.org/man/zh/man-port-scanning-basics.html#:~:text=开放的端口不响应,-就是一个例子" rel="noopener" target="_blank">开放端口不响应&lt;/a> 的意思。UDP，IP协议， FIN，Null，和Xmas扫描可能把端口归入此类。&lt;code>close | filtered&lt;/code> 同理 ， 它只可能出现在IPID Idle扫描中。&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>unfiltered&lt;/td>
&lt;td>Nmap 根据目前的探测无法确定它们是关闭还是开放（极少出现的情况吧）&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/li>
&lt;li>
&lt;h3 id="主机发现">
 主机发现
 &lt;a class="anchor" href="#%e4%b8%bb%e6%9c%ba%e5%8f%91%e7%8e%b0">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;li>
&lt;h3 id="扫描方式">
 扫描方式
 &lt;a class="anchor" href="#%e6%89%ab%e6%8f%8f%e6%96%b9%e5%bc%8f">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;li>
&lt;h3 id="服务探测">
 服务探测
 &lt;a class="anchor" href="#%e6%9c%8d%e5%8a%a1%e6%8e%a2%e6%b5%8b">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;li>
&lt;h3 id="选项样例">
 选项样例
 &lt;a class="anchor" href="#%e9%80%89%e9%a1%b9%e6%a0%b7%e4%be%8b">#&lt;/a>
&lt;/h3>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://nmap.org/man/zh/index.html" rel="noopener" target="_blank">https://nmap.org/man/zh/index.html&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="options">
 Options
 &lt;a class="anchor" href="#options">#&lt;/a>
&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>option&lt;/th>
&lt;th>expalin&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&amp;ndash;packet-trace&lt;/td>
&lt;td>打印数据包&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;ndash;traceroute&lt;/td>
&lt;td>路由追踪&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="principle">
 Principle
 &lt;a class="anchor" href="#principle">#&lt;/a>
&lt;/h2>
&lt;h2 id="examples">
 Examples
 &lt;a class="anchor" href="#examples">#&lt;/a>
&lt;/h2>
&lt;h2 id="references">
 References
 &lt;a class="anchor" href="#references">#&lt;/a>
&lt;/h2></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/openssl/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/openssl/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introopenssl">
 Intro(OPENSSL)
 &lt;a class="anchor" href="#introopenssl">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;h3 id="证书类型">
 证书类型
 &lt;a class="anchor" href="#%e8%af%81%e4%b9%a6%e7%b1%bb%e5%9e%8b">#&lt;/a>
&lt;/h3>
&lt;p class="warn">暂时记录一个 x509 (


 &lt;a href="https://www.rfc-editor.org/rfc/rfc5280.html" rel="noopener" target="_blank">rfc&lt;/a>，


 &lt;a href="https://zh.wikipedia.org/wiki/X.509#证书组成结构" rel="noopener" target="_blank">wiki&lt;/a>)。这种格式一般广泛应用于Web浏览器和服务器之间的SSL/TLS加密通信。
&lt;br>对于这种证书的编码格式有 &lt;strong>der&lt;/strong>, &lt;strong>pem(privvaccy-enhanced mail)&lt;/strong> 等。且可以认为 pem 是 der 二进制的一种 base64编码。可以如下验证：
&lt;br>&lt;br>&lt;code>1.&lt;/code> 下载网站证书并写入到文件：（不是直接下载，而是在 https 握手过程中会携带 


 
 

 
 
 
 
 
 
 
 
 
 &lt;a href='https://archive-w.netlify.app/devops/network/tls-ssl/#hp-certificate-%e5%ae%9e%e4%be%8b%e5%88%86%e6%9e%90' rel="noopener" class="internal-link" data-src="https://archive-w.netlify.app/devops/network/tls-ssl/#hp-certificate-%e5%ae%9e%e4%be%8b%e5%88%86%e6%9e%90">证书数据&lt;/a>，openssl 会在这个过程中打印出来，然后我们用工具提取即可）
&lt;br>&lt;span style='padding-left:1.2em'>&lt;code>1.1.&lt;/code> &lt;code>openssl s_client -connect wtfu.site:443 &amp;gt; pubkey.pem&lt;/code> (运行可能会卡住，CTRL+c 终止就行)
&lt;br>&lt;span style='padding-left:4.2em'>查看 pubkey.pem 内容：删除&lt;code>-----BEGIN CERTIFICATE-----&lt;/code>和&lt;code>-----END CERTIFICATE-----&lt;/code>之外多余的内容。
&lt;br>&lt;span style='padding-left:1.2em'>&lt;code>1.2.&lt;/code> 或者一步到位：&lt;code>openssl s_client -connect wtfu.site:443 &amp;lt;/dev/null 2&amp;gt;/dev/null | sed -n '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' &amp;gt; pubkey.pem&lt;/code>
&lt;br>&lt;br>&lt;code>2.&lt;/code> 转换：pem -&amp;gt; der，将除了第一行和最后一行的内容进行 base64 解码，然后写入文件&lt;code>sed '1d;$d' pubkey.pem | base64 -d &amp;gt; pubkey.der&lt;/code>
&lt;br>&lt;code>3.&lt;/code> 提取 pem 证书中的公匙并显示相关信息：&lt;code>openssl x509 -in pubkey.pem -pubkey -noout | openssl ec -pubin -text -noout&lt;/code>
&lt;br>&lt;code>4.&lt;/code> 提取 der   证书中的公匙并显示相关信息：&lt;code>openssl x509 -in pubkey.der -pubkey -noout | openssl ec -pubin -text -noout&lt;/code>
&lt;br>&lt;br>&lt;img src="https://archive-w.netlify.app/.images/devops/os/util/openssl-cer-format-01.png" alt="" width="100%">
&lt;br>&lt;br>或者也可以通过 


 &lt;a href="https://asn1js.eu/" rel="noopener" target="_blank">asn1在线解析&lt;/a> 查看 pubkey.der 文件是否正确（DER 本质上是 


 &lt;a href="https://zh.wikipedia.org/wiki/ASN.1" rel="noopener" target="_blank">ASN.1&lt;/a> 结构类型的）。
&lt;br>&lt;br>另外可以计算 sha-256 指纹(对应 chrome 浏览器证书基本信息中的值)，包括 证书和公匙
&lt;br>证书：&lt;code>cat pubkey.der | shasum -a 256&lt;/code>，或者 &lt;code>grep -v ^- pubkey.pem | base64 -d | shasum -a 256&lt;/code>。
&lt;br>公匙：&lt;code>openssl x509 -in &amp;lt;pubkey.der | pubkey.pem&amp;gt; -pubkey -noout | grep -v ^- | base64 -d | shasum -a 256&lt;/code>。&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/ranger/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/ranger/</guid><description>&lt;p>hello&lt;/p></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/xargs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/xargs/</guid><description>&lt;p class="tip">用于参数转换，与不支持管道输入的命令搭配使用，比如 &lt;code>ls&lt;/code>.&lt;/p>
&lt;h2 id="options">
 Options
 &lt;a class="anchor" href="#options">#&lt;/a>
&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>options&lt;/th>
&lt;th>explain&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>-a&lt;/td>
&lt;td>file 从文件中读入作为stdin&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-e flag&lt;/td>
&lt;td>注意，有的时候可能为-E，flag必须是一个以空格分隔的标志，当分析到含有flag这个标志的时候就停止&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-p&lt;/td>
&lt;td>每当执行一个argument的时候会询问用户&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-n num&lt;/td>
&lt;td>表示命令在执行的时候一次用几个参数，默认是所有&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-t&lt;/td>
&lt;td>表示先打印命令，再执行&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-i | -I&lt;/td>
&lt;td>参数占位符，{}，%，等都可以使用&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-s&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-r no-run-if-empty&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-L num&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-d delim&lt;/td>
&lt;td>默认的xargs的分隔符是回车，argument的分隔符是空格。这里修改的是xargs的分隔符&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-x exit&lt;/td>
&lt;td>主要配合 -s使用&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>-P&lt;/td>
&lt;td>修改最大进程数，可以并发执行&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="cation">
 CATION
 &lt;a class="anchor" href="#cation">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">cat &amp;gt; file &amp;lt;&amp;lt;EOF
a b c d e
f g h i j k
l m n o p q r
s t u v
w x y z
EOF

cat file | xargs -L 2 -I {} echo '{}' # 这个命令中 -L 和 -I 指令冲突。所以不会出现预期效果，可以多加一个xargs使用,比如下面
cat file | xargs -L 2 | xargs -I {} echo '{}' # 多加后出现的效果。
&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="reference">
 Reference
 &lt;a class="anchor" href="#reference">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>


 &lt;a href="https://www.runoob.com/linux/linux-comm-xargs.html" rel="noopener" target="_blank">https://www.runoob.com/linux/linux-comm-xargs.html&lt;/a>&lt;/li>
&lt;li>


 &lt;a href="https://www.cnblogs.com/chentiao/p/16543679.html" rel="noopener" target="_blank">https://www.cnblogs.com/chentiao/p/16543679.html&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title/><link>https://archive-w.netlify.app/devops/os/util/xxd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://archive-w.netlify.app/devops/os/util/xxd/</guid><description>&lt;ul>
&lt;li>
&lt;h2 id="introxxd">
 Intro(xxd)
 &lt;a class="anchor" href="#introxxd">#&lt;/a>
&lt;/h2>
&lt;div class="outer yosemite">&lt;div class="dot red">&lt;/div>&lt;div class="dot amber">&lt;/div>&lt;div class="dot green">&lt;/div>&lt;/div>
&lt;div class="code-toolbar">&lt;pre data-lang="shell" data-line="7,13,16,22-24" data-file="options" class="language-shell line-numbers" style="max-height: none">&lt;code class="language-shell">vscode ➜ /workspaces/c_learning/multi-elf (master) $ xxd --help
Usage:
 xxd [options] [infile [outfile]]
 or
 xxd -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]
Options:
 -a toggle autoskip: A single '*' replaces nul-lines. Default off.
 -b binary digit dump (incompatible with -ps,-i). Default hex.
 -C capitalize variable names in C include file style (-i).
 -c cols format &amp;lt;cols&amp;gt; octets per line. Default 16 (-i: 12, -ps: 30).
 -E show characters in EBCDIC. Default ASCII.
 -e little-endian dump (incompatible with -ps,-i,-r).
 -g bytes number of octets per group in normal output. Default 2 (-e: 4).
 -h print this summary.
 -i output in C include file style.
 -l len stop after &amp;lt;len&amp;gt; octets.
 -n name set the variable name used in C include output (-i).
 -o off add &amp;lt;off&amp;gt; to the displayed file position.
 -ps output in postscript plain hexdump style.
 -r reverse operation: convert (or patch) hexdump into binary.
 -r -s off revert with &amp;lt;off&amp;gt; added to file positions found in hexdump.
 -d show offset in decimal instead of hex.
 -s [+][-]seek start at &amp;lt;seek&amp;gt; bytes abs. (or +: rel.) infile offset.
 -u use upper case hex letters.
 -R when colorize the output; &amp;lt;when&amp;gt; can be 'always', 'auto' or 'never'. Default: 'auto'.
 -v show version: &amp;quot;xxd 2023-10-25 by Juergen Weigert et al.&amp;quot;.
&lt;/code>&lt;/pre>&lt;/div>
&lt;/li>
&lt;/ul></description></item></channel></rss>