Today, I wrote a long shell script with a lot of nested structures. When I finally ran it, the error syntax error: unexpected end of file
appeared.
I have encountered this before, and it often occurs when the win
system transfers the script file to the unix
system, but this time I wrote it in the Linux environment, and this problem does not exist, and it is useless to change it. About system file format conversion:
dos2unix #command line
:set ff #View the system format of the file in vim
:set fileformat=unix #Change the system file format to unix in vim
I checked the Internet and found all the answers with the wrong file format!
Finally found a suggestion in StackOverflow: Count the number of if...fi
and for...done
is not the same. Because the structure is more complicated, I really found a fi
missing somewhere, and finally solved it.