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

#!/bin/bash wordcount=$(wc -w \'pizza\') wordcountday=[$wordcount/20] wordcountd

ID: 3887862 • Letter: #

Question

#!/bin/bash
wordcount=$(wc -w 'pizza')
wordcountday=[$wordcount/20]
wordcountdaypid=[$wordcountday/29447]
echo $wordcountdaypid


This is my script right now. I am trying to read a file named "pizza", count the words in it, divide by 20, divide by 29447, and then display the number. My output so far is [[39 pizza/20]/29447]. For some reason my syntax is off and pizza is being registered as a string, not a file that is being read. The 39 indicates that the word count is being registered however... And lastly, the last line shows that I am asking for a value, however this syntax is just not right. Any help would be great, thank you.

Explanation / Answer

Dear Student,

below is the correct script. Please try to run the script in you system. expr is used to calculate any mathematical equation.

Script:

-----------------------------------------------------------------------------------------------------------------------------------------

#!/bin/bash

wordcount=`wc -c < pizza`

wordcountday=`expr $wordcount / 20`

wordcountdaypid=`expr $wordcountday / 29447`

echo $wordcountdaypid

Note: I do not havae pizza file in my system that is why i have not attached the output.However now you can try to execute the script you will get the correct output.

------------------------------------------------------------------------------------------------------------------------------------------

Kindly Check and Verify Thanks...!!!