Notepad ++ execution error when writing shell statement, notepadshell
I think the vi format scheduling is not very good. I used notepad ++.
During a shell statement debugging, it was found that there were no errors when the shell copied from notepad ++ was executed in Linux! However, when you upload the shell script written by notepad to Linux for debugging, an error indicating that the command cannot be found is reported! Think about it. The root cause of the problem must be Nodepad ++. Then, find the cause,It turns out to be a format conversion problem.
Temporary solution:
Permanent solution:
Open in notepad ++, set, preference
How to read variable values in case statements in shell scripts? I wrote a script and reported an error after running it.
Read CHOICE
Case $ CHOICE in
1) mountusb ;;
2) umountusb ;;
3) display ;;
4) cpdisktousb ;;
5) cpusbtodisk ;;
0) quit ;;
*) Echo "Invalid Choice! Correct Choice is (0--5 )"
Sleep 4 clear ;;
The logic of the if statement in shell is incorrect.
Use the $ symbol to get the variable value (add $ before the variable ).
Test = 1
If [$ test-eq 1]; then
Echo "test = 1"
Elif [$ test-eq 0]; then
Echo "test = 0"
Else
Echo "other"
Fi
------------------------------
Supplement: test is a shell built-in command used to test the expression. The variable name you define is exactly the same.
Your script will report a syntax error here: [: test: integer expression expected
It may also be related to what shell you are using.
Replace it with count, and I am also prompted with a syntax error, [: count: integer expression expected
Because-eq is used for integer comparison, the script expects that both sides of this operator are integer or integer expressions.
But I did report an error on this side, that is, the execution is not allowed. Please use Baidu hi to facilitate communication.