我有一个包含以下信息的文本文件
信息.txt
1,susan,12345678,partTimeStaff,1
2,john,54243214,fullTimeStaff,3
3,mary,53214567,contractStaff,3
4,gerald,14546752,partTimeStaff,0
5,joe,14234567,fullTimeStaff,2
6,joshua,11234567,contractStaff,2
我正在尝试获取员工的姓名和工作经验的数量并将其打印出来(“staffName 工作经验总年数:WorkExperience”)
这是我目前拥有的
printOutName=$(cat "info.txt" | cut -d, -f2,4,5 | sort -r -t, -k2 | grep "partTimeStaff" | cut -d, -f1)
printOutYOfExp=$(cat "info.txt" | cut -d, -f2,4,5 | sort -r -t, -k2 | grep "partTimeStaff" | cut -d, -f3)
echo "part Time Staff"
echo -e "$printOutName total years of work experience: $printOutYOfExp"
我注意到输出下面显示的输出有问题
part Time Staff
gerald
susan total years of work experience : 0
1
预期产出
part Time Staff
gerald total years of work experience : 0
susan total years of work experience : 1
提前致谢