regex - Bash 主机检查两列

标签 regex linux bash

我有包含主机名的 A 列和 B 列。如果主机从 A 列的第一行回答,则继续到 A 列的第二行。如果主机没有从 A 列回答,则检查 B 列同一行的主机。如果 B 列的第二个主机没有回答,则打印错误主机。

最佳答案

"How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?"

while read -r host1 host2; do
  somethingsomething "$host1" || somethingsomething "$host2" || { echo "#fail" >&2 ; }
done < input.lst

关于regex - Bash 主机检查两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29043839/

相关文章:

linux - 在 GNU Bash 4.3 的 Bash shell 脚本中提示用户确认

regex - 如何在vi中替换NUL?

linux - 存储库 : Cannot retrieve repository metadata (repomd. 错误 : base. xml) 请验证其路径并重试

Linux cmd将文件复制到现有文件而不覆盖它

python - 如何独立于语言安装(linux)在python中获取用户桌面路径

linux - 为什么 repoquery 输出错误的文件列表?

python - 如何使用 shell 命令将目录作为参数传递给 python 脚本?

javascript - 比较和索引 Javascript 数组中的正则表达式

c# - 正则表达式匹配除 C# 中引号中的字符串以外的所有内容

python - 如何在Python中查找特定文件