在文本文件中搜索字符串,并在搜索到的字符串后输出该行

时间:2017-12-04 14:21:11

标签: tcl

我正在寻找一个搜索文本文件的解决方案,让我们说“Hello”,每次在文本文件中找到“Hello”时,它会跳到下一行并将整行打印成新文本文件

示例文本文件内容:

Hello
password:xxxxx user:xxxxx
Foo
password:xxxx user:xxxxxx
Foo
password:xxxxx user:xxxxx
Hello
password:xxxxx user:xxxxx
Foo
password:xxxx user:xxxx

1 个答案:

答案 0 :(得分:0)

试试这个:

  if {[string match $::StringToFind $line]} {
  continue
 }