bash-查找行(匹配字符串)以文本和前向斜线开头
我正在尝试在文件中找到(匹配字符串)行,该线从 test /< /strong>开始(开始),
这起作用,使用whitespace进行测试:
if [[ "$LINE" == 'TEST '* ]]
then
echo $LINE
fi
带有前向斜线的TEXH,不起作用 - 我该如何使此操作?
if [[ "$LINE" == 'TEST /'* ]]
then
echo $LINE
fi
有建议吗?
我还有其他红色主题,问题,但没有运气..........
I am trying to find (match string) line in file, that starts (begin) with TEST /
this works, TEST with whitespace:
if [[ "$LINE" == 'TEST '* ]]
then
echo $LINE
fi
texh with forward slash, doesnt work - how can I make this works?
if [[ "$LINE" == 'TEST /'* ]]
then
echo $LINE
fi
any advice?
I have red other topics, questions, but no luck..........
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码在我这边没问题。
但是,如果您想选择以某些模式开头的行,我建议您=〜二进制操作员。更多信息,请访问 httpps:// https://www.gnu.orgg/savannahahah - 检查/gnu/bash/harual/bash.html
例如
Your code works just fine no problem on my side.
But if you want to select lines that start with some patterns i suggest you the =~ binary operator. More info at https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html
e.g