[命令] Linux 命令 tee (将输出内容保存到文件里)

内容一:tee 命令的格式

# tee [option] [file]......

内容二:tee 命令的选项

1) -a 或者 –append 将输出内容添加到文件里内容的末尾
2) -i 或者 –ignore-interrupts 忽略中断信号
3) –help 显示帮助信息
4) –version 显示版本信息

内容三:tee 的使用案例

3.1 将输出内容添加到另一个文件里内容的末尾

# echo 'tee test' | tee -a test.txt
tee test
# tail -1 test.txt
tee test

(补充:这里以将输出内容 ‘tee test’ 添加到另一个文件 test.txt 里内容的末尾为例)

3.2 将文件内容添加到另一个文件里内容的末尾

# cat test1.txt | tee -a test2.txt
test1
# tail -1 test2.txt
test1

(补充:这里以将 test1.txt 文件里的内容添加到另一个文件 test2.txt 里内容的末尾为例)

3.3 将输出内容变成另一个文件里的所有内容

# echo 'tee test' | tee test.txt
tee test
# cat test.txt
tee test

(补充:这里以将输出内容 ‘tee test’ 变成另一个文件 test.txt 里的所有内容为例)

3.4 将文件内容变成另一个文件里的所有内容

# cat test1.txt | tee -a test2.txt
test1
# cat test2.txt
test1

(补充:这里以将 test1.txt 文件里的内容变成另一个文件 test2.txt 里的所有内容为例)

[内容] CVE 简介

内容一:什么叫 CVE

CVE 全称是:Common Vulnerabilities and Exposures,翻译成中文是:常见脆弱性和暴露,是一个业界统一的脆弱性和暴露。

内容二:CVE 的常用格式

CVE-2016-4658,其中 2016-4658 是编号

内容三:CVE 的用途

用于标签系统和应用的漏洞,并实现了一个漏洞数据库以进行漏洞的查询和管理

内容四:CVE 的网站

4.1 CVE 官方网站

https://www.cvedetails.com

4.2 RedHat CVE 官方网站

4.2.1 RedHat CVE 官方网站

https://access.redhat.com/security/security-updates/#/cve

4.2.2 RedHat CVE 勘误官方网站

https://access.redhat.com/management/errata

4.3 openSUSE CVE 官方网站

openSUSE CVE 安全补丁官方网站

https://lists.opensuse.org/archives/list/security-announce@lists.opensuse.org/

4.4 SUSE CVE 官方网站

SUSE CVE 安全补丁官方网站

https://www.suse.com/security/cve/

内容五:显示软件 CVE 信息

5.1 显示软件 CVE 信息的变更历史

# rpm -q openssh-clients --changelog | grep -i cve

(补充:这里以显示 openssh-clients 软件的 CVE 信息的变更历史为例)

5.2 显示软件现在的版本是否修复 CVE 漏洞

# rpm -qpi --changelog redis-6.0.14-6.8.1.x86_64.rpm |grep -E '32675'
- Fix CVE-2021-32675, Denial Of Service when processing RESP request
  (CVE-2021-32675, bsc#1191303)
  * cve-2021-32675.patch

(补充:这里以确认 redis-6.0.14-6.8.1.x86_64.rpm 软件包是否已修复 CVE-2021-32675 为例)

[工具] Shell 读取一个文件 (以列的方式)

介绍

作者:朱明宇
名称:读取 1 个文件(以列的方式)
作用:读取 1 个文件,并把里面的内容以空格作为分割符,分成 3 列显示出来

使用方法:
1. 给此脚本添加执行权限
2. 执行此脚本,并在输入此命令时,在后面添加要被读取文件

脚本

#!/bin/bash

file=$1

if [[ $# -lt 1 ]];then
        echo "This file does not exist"
        exit
fi

while read -r f1 f2 f3
do
        echo "file 1:$f1 ==> file 2:$f2 ==> file 3:$f3"

done < "$file"

[工具] Shell 读取一个文件 (以行的方式)

介绍

作者:朱明宇
名称:读取 1 个文件(以行的方式)
作用:读取 1 个文件(以行的方式),并把里面的内容显示出来

使用方法:
1. 给此脚本添加执行权限
2. 执行此脚本,并在输入此命令时,在后面添加要被读取文件

脚本

#!/bin/bash

file=$1

if [[ $# -lt 1 ]];then
        echo "This file does not exist"
        exit
fi

while read line
do
        echo "$line"

done < "$file"