Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何在shell脚本中从文件中提取子字符串_Bash_Shell_Unix - Fatal编程技术网

Bash 如何在shell脚本中从文件中提取子字符串

Bash 如何在shell脚本中从文件中提取子字符串,bash,shell,unix,Bash,Shell,Unix,我有一个文件,它每次都在生成,每次用粗体显示的id都在更改 临时文本 |螺旋输送器5d多VT相对的5E2FEA0FFE049769C682C13| 每晚| |螺旋钻分布图5e2fea151a4cc938e465d8f2| 每晚| 我只想提取粗体字符串。假设您的文件名为test.txt,启动此命令 cat test.txt | cut -f3 -d\| 说明: “剪切”命令过滤由给定分隔符分隔的文本剪切字段 -f3 --> the third parameter -d\| --->

我有一个文件,它每次都在生成,每次用粗体显示的id都在更改

临时文本

|螺旋输送器5d多VT相对的5E2FEA0FFE049769C682C13| 每晚| |螺旋钻分布图5e2fea151a4cc938e465d8f2| 每晚|


我只想提取粗体字符串。

假设您的文件名为test.txt,启动此命令

cat test.txt | cut -f3 -d\|
说明:
“剪切”命令过滤由给定分隔符分隔的文本剪切字段

-f3 -->  the third parameter
-d\| --->  with | as delimiter
使用awk

awk -F'|' '{print $3}' log.txt

到目前为止你试过什么?