gpt4 book ai didi

Linux 逐行读取文件并报告

转载 作者:太空宇宙 更新时间:2023-11-04 05:00:25 24 4
gpt4 key购买 nike

我有两个文件,这是在执行几个脚本并运行几个查询后获得的,这两个文件的差异(每个文件有两列,名称和数字)现在存储在第三个文件中第三个文件包含三列!

!  <Employee Name1> <Employee Number1>
! <Employee Name1> <Employee Number2>
! <Employee Name3> <Employee Number4>
! <Employee Name3> <Employee Number5>

如何一次读取文件 2 行并报告类似内容

<Employee Name1> has different Employee ID.It is <Employee Number1> in File1 and <Employee Number2> in File2 

最佳答案

使用 bash,您可以在 while 循环中读取 2 行:

while read -r _ name num1; read -r _ name num2; do
echo "$name has different Employee ID.It is $num1 in File1 and $num2 in File2"
done < file3

关于Linux 逐行读取文件并报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34540300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com