linux - Linux - Diff number of lines in 2 set of files
问题描述
I have 2 folders which contains 2 set of files.
Folder1
input1.csv
input2.csv
...
Folder2
output1.json
output2.json
...
Ideally, the number of lines in input1 should be same as output1, the number of lines in input2 should be same as output2, and so on.
I need a Linux command to check this automatically and tell me which files are different.
Basically,
If wc -l input1 == wc -l output1,
then skip;
else
show input1 file name (or output1 file name)
repeat for all other files.
How can I achieve this?
解决方案
这样的事情可能会有所帮助
arr=("1.in" "2.in")
arr2=("1.out" "2.out")
for i in ${!arr[@]}; do
v_in=$(wc -l < ${arr[$i]}) ;
v_out= $(wc -l < ${arr2[$i]}) ;
if [ v_in -ne v_out ] then
echo "not equal"
else
echo "equal"
fi
done
推荐阅读
- fetch - 如何在 nuxt 的 fetch 函数中调度存储操作?
- mongodb - 使用 Spring MongoDB 创建聚合查询 | 将小时数添加到投影中的日期
- vue.js - Vue Quassar Standalone 示例不起作用
- regex - 使用正则表达式解析谷歌表格脚本中公式(先例)中的所有单元格引用
- android - 库依赖资源覆盖 Android 中的主要源集
- assembly - 使用按位运算将一个数字的低十六进制数字与另一个数字的高十六进制数字交换
- c# - 使用 C# 备份远程 Oracle 数据库
- jsf - “com.sun.faces.context.FacesContextImpl”类没有“currentPhaseId”属性
- docker - Dockerfile CMD 无法找到入口点文件
- linux - 如何使用 Logrotate 保留 14 天的日志?