Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编写一个shell脚本以查找在给定部门名称中工作的员工数。(UNIX)_Shell_Unix_Scripting - Fatal编程技术网

编写一个shell脚本以查找在给定部门名称中工作的员工数。(UNIX)

编写一个shell脚本以查找在给定部门名称中工作的员工数。(UNIX),shell,unix,scripting,Shell,Unix,Scripting,查找给定部门中的多个员工 EmpID|Name|Department 1|John|IT 2|Jack|IT 3|Kevin|Sales 4|Daniel|HR 5|Sam|Sales 部门的输出,它将给出如下答案 2 它实际上只是带有计数参数的grep grep -c "IT" file_with_employees.txt 这种方法的问题:如果你有一个“小猫先生”,在销售部工作,他也会被计算在内:-)你说得对。在这种特定的格式和任务中,可以通过将中的“it$”(意思

查找给定部门中的多个员工

EmpID|Name|Department
1|John|IT
2|Jack|IT
3|Kevin|Sales
4|Daniel|HR
5|Sam|Sales
部门的输出,它将给出如下答案

2

它实际上只是带有计数参数的grep

grep -c "IT" file_with_employees.txt

这种方法的问题:如果你有一个“小猫先生”,在销售部工作,他也会被计算在内:-)你说得对。在这种特定的格式和任务中,可以通过将
中的“it$”
(意思是它后面跟行尾)打灰来避免它;-)你试了什么?