Ahess97 Posted December 10, 2021 Posted December 10, 2021 Hello, I am attempting to create a NPS calculator in Alfred where I only have to enter the numbers with command and it provides the score for me. (For context, this website has the formula on the bottom.) I believe based on the error log I am getting, it is something with the Script I have set up using bin/zsh. Is anyone able to provide some assistance? Thanks in advance! Austin PS: Here are the test numbers I am using starting with 0 (red) and going to 10 (green): 1,0,0,0,0,2,1,4,2,4,26
vitor Posted December 10, 2021 Posted December 10, 2021 Welcome @Ahess97, In bash you access variables with ${var}, not {var}. Also, you’re calling bc but doing nothing with it, as if you were calling it interactively in a Terminal. This being a script, you need to give your data as the input to bc. Use <<< to feed data, or < to feed a file. Meaning what you want is: bc -l <<< "(((${nps11}+${nps10})-(${nps7}+${nps6}+${nps5}+${nps4}+${nps3}+${nps2}+${nps1}))/(${nps11}+${nps10}+${nps9}+${nps8}+${nps7}+${nps6}+${nps5}+${nps4}+${nps3}+${nps2}+${nps1}))*100"
Ahess97 Posted December 12, 2021 Author Posted December 12, 2021 Thank you! That is super helpful to know how terminal and scripts differ. One final question: my output has many 0s following the NPS score. (65.00000000000000000000). I think using the transform function using regex would solve this problem, but I don't know much about regex
deanishe Posted December 12, 2021 Posted December 12, 2021 7 hours ago, Ahess97 said: I don't know much about regex This seems to work: But regular expressions aren't really the right tool for this kind of job.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now