LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I make a list? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-make-a-list-4175631966/)

ash997 06-14-2018 05:21 PM

How do I make a list?
 
I need to make a list of the number of employees working in each department. With the name of each department once and the the number of employees. The file contains the following:
04,Hendrix,James,Engineering,9
889,Wallace,Mia,Accounting,8
096,Uffhark,Joan,Administration,9
120,Carrington,Blake,Accounting,8
053,Draper,Don,Marketing,3
413,Zappa,Francesco,Engineering,9 285,Gunvalson,Victoria,Engineering,9 744,Watts,Charles,Administration,8
409,Wilson,Brian,Engineering,9
346,McCormick,Kenneth,Marketing,2
070,Berlin,Rachel,Marketing,2
555,Zombie,Robert,Administration,7
217,Burns,Fahr,Accounting,8
154,Tennille,Antoinette,Engineering,9 843,Trakand,Elayne,Administration,8 654,Grumby,Jonas,Administration,7
026,Corleone,Michael,Marketing,3
599,March,Christopher,Engineering,9
808,Mann,Yoda,Engineering,9

RandomTroll 06-14-2018 05:27 PM

Looks like homework. Great band!

ash997 06-14-2018 05:42 PM

I'm thinking that I have to use this command but I'm not sure
<file1 cut -d',' -f4 | sort -n | uniq -c

syg00 06-14-2018 06:01 PM

Did you try it ?.
What happened ?.
What was the reason ?.

ash997 06-14-2018 06:27 PM

yes I tried it and I got this -bash: sorn: command not found
-bash: file1: No such file or directory

BW-userx 06-14-2018 06:34 PM

strut does not work in bash, hum.. what class are you taking? what programming lang is it suppose to be in. else you could just go old school, and use a piece of paper and pencil to write out a list. :D

ash997 06-14-2018 06:38 PM

The class is Linux 1 and I don't know what language.

BW-userx 06-14-2018 06:58 PM

Then how is anyone going to be able to help you?

ash997 06-14-2018 06:59 PM

I guess It's bash

syg00 06-14-2018 10:53 PM

Quote:

Originally Posted by ash997 (Post 5867728)
yes I tried it and I got this -bash: sorn: command not found
-bash: file1: No such file or directory

So you got messages and you chose to ignore them ?. And you want use to tell you why ?. Not going to happen.

Looks like you found that command string somewhere and used it without understanding what it is. Linux comes with a help system for commands called "man" - but only for commands actually installed. So "man sort" (no quotes) will work, but "man sorn" won't for the same reason as in you messages. Use "q" (no quotes) to exit the manpage.
Linux is case sensitive as well as expecting you to type names correctly.

All this should be provided in a beginner linux course.

AwesomeMachine 06-14-2018 11:48 PM

Just a footnote: in my experience, instructors assign homework problems NOT because they don't know the answer, but because the task cannot be performed by students without them actually learning something. By approaching the problem with sound reasoning, and developing a solution based on sound research, the student not only learns how to solve the assigned task, but many other similar problems as well.

It would help us to know what you are starting with and what the result should be. So, could you type out the desired out file so at least 'you' know what you want it to look like? I can tell you that you probably want to look into writing a script using awk and/or sed. I doubt whether you'd be expected to use PERL in your intro class.


All times are GMT -5. The time now is 02:21 PM.