Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Bash Script via VIM In a file called votingOptions , write a bash script that lo

ID: 3916599 • Letter: B

Question

Bash Script via VIM

In a file called votingOptions, write a bash script that looks at the 2012_GENERAL.txt (see below) file in the directory and prints the total unique number of candidate names in the file. Consider anything in the NAME column a candidate name.
The provided file is tab separated, meaning that visually, lines may not appear aligned, but the content is aligned with one tab in between each column.

Note: Easiest way to split tab separated files in bash. Look at the cut command with the -f flag.

***Provide an explanation of your answer***

2012_GENERAL.txt file
https://www.dropbox.com/s/n5kvxb3ead1l7en/2012_GENERAL.txt?dl=0

Explanation / Answer

You can choose any one the above solution.In this first we printed the text without the first line because it[ is a header tail -n +2 2012_GENERAL.txt] and next step we have taken the name field which is 5[cut -f 5 ] after that we sorted out the all names[sort] and printed uniq names [uniq] next we counted the number of lines[wc -l].

some Extra explanation:

:D

awk 'BEGIN {FS=" "}; NR>1 {print $5}'

Here we have used awk added tab as delimeter and printing name column without the header

Please feel free to ask if have any queries.