Using bash to write a script, the script must use the form of function to calculate 1 + 2 + 3 + 4 + +N is the parameter of the script. If there is no parameter, it will prompt an error. If there is an error in the running process, the error information should be discarded.
An incomprehensible sentence:
If there is an error in the running process, the error message should be discarded.
May be used: > / dev / null
But I don’t know how or where to use it.
Attach my own code (except for the sentence that I can’t understand, everything else has completed the programming requirements)
#!/bin/bash i=1 sum=0 if [ $# -lt 1 ];then Echo "you forgot to enter the script parameters" else while [ $1 -ge $i ] do sum=$[$sum+$i] ((i++)); done echo $sum echo $i fi
There should be examples. Correct input / output wrong input / output
This is the last sentence. I can’t program.