我如何获取并过滤在终端中打印的信息

问题描述 投票:0回答:1

如果终端打印(回声)一串字符串如:

aPath
aSecondPath
aThirdPath

我如何过滤这些并找到ThirdPath例如?

bash shell terminal
1个回答
0
投票

使用GNU grep

printf '%s\n' aPath aSecondPath aThirdPath | grep -o ThirdPath

省略-o打印整行“aThirdPath”。

© www.soinside.com 2019 - 2024. All rights reserved.