mardi 5 mai 2015

Bash, print 0 in terminal each time a non recognised argument is input

I have a bash program which extracts marks from a file that looks like this:

 Jack ex1=5 ex2=3 quiz1=9 quiz2=10 exam=50

I want the code to execute such that when I input into terminal:

./program -ex1 -ex2 -ex3

Jack does not have an ex3 in his data, so an output of 0 will be returned:

Jack 5 3 0

how do I code my program to output 0 for each unrecognized argument?

Aucun commentaire:

Enregistrer un commentaire