php - 寻找领域中的共同值(value)

标签 php linux shell unix

假设我有 2 个包含值的文件:

文件A:

name        occupation      grade
ishaan      doctor          best
sinha       engineer        worst
palak       sales           good
nishant     commissioner    best
ishaan      doctor          good
palak       sales           okey

文件B:

name        grade       occupation
ishaan      best        doctor
sinha       worst       engineer
palak       good        sales
nishant     best        commissioner
ishaan      good        doctor
palak       okey        sales

我想使用 shell 脚本仅打印两个文件中 Occupation 字段中的共同值。如果您建议 awk 实用程序,请同时解释该命令(带参数)。

最佳答案

认为这不是一个好的答案,但你试试这个..

运行 for 循环获取记录并使用 array_push() 将每个记录推送到新数组中;

并检查 if(!in_array()) 不在数组中,然后显示新记录..

关于php - 寻找领域中的共同值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29763125/

相关文章:

php - 每次数据库调用时手动 "SET NAMES utf8"的替代方案

php - 访问 PHP 关联数组,索引表示为字符串

ruby-on-rails - 在 Ubuntu 14.04 上安装 Ruby 时出错

git - 仅 Git 命令的制表符完成卡住

linux - 在 shell 变量中提取文件的最后一个和倒数第二个字符串

linux - shell语言的数据组

php - 使用 : the MySQL or PHP md5 function? 什么更快/更好

php - 无法通过 zoho api 上传文档

linux - 同时 DMA 到用户内存

php - 如何从pdf中提取文本层和背景层?