小编Dra*_*ana的帖子

我有四个文件,每个文件 10 行,如何获得如下输出

我有4个文件。我需要检查所有文件的行数是否相同。

如果行数不同,我需要检测它并输出,例如:

#file1 - 10 lines, file2 - 9 lines, file3 - 10 lines, file4 - 10 lines
Line are miss matched
Number of lines 10 = 9 = 10 = 10
Run Code Online (Sandbox Code Playgroud)

如果它们相等,我想逐行合并文件,如下所示:

文件:

#file1
10 
12
11

#file2
Arun
kamal
babu

#file3
300
200
400

#file4
spot1
spot4
spot5
Run Code Online (Sandbox Code Playgroud)

输出:

Set1
10
Arun
300
spot1

Set2
12
kamal
200
spot4

Set3
11
babu
400
spot5
Run Code Online (Sandbox Code Playgroud)

我的代码:

#

id_name=`cat file2`
echo $id_name

id_list=`cat file1`
echo $id_list

#

id_count=`cat file3`
echo …
Run Code Online (Sandbox Code Playgroud)

scripting perl shell-script

-2
推荐指数
2
解决办法
180
查看次数

标签 统计

perl ×1

scripting ×1

shell-script ×1