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 你好 密码:xxxxx用户:xxxxx 福 密码:xxxx用户:xxxxxx 福 密码:xxxxx用户:xxxxx 你好 密码:xxxxx用户:xxxxx 福 密码:xxxx用户:xxxx 试试这个:Tcl 在文本文件中搜索字符串,并输出所搜索字符串后的行,tcl,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 你好 密码:xxxxx用
if {[string match $::StringToFind $line]} {
continue
}
看到这里了吗?您是在搜索行中的任何位置的Hello,还是整行都应该等于Hello?我会让您参考,尤其是
打开
,关闭
和获取