In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Someone else wrote a shell to try it out in linux, and the error report is as follows:
After searching carefully, I still can't find any errors. I always report to syntax error near unexpected token `{
I searched the Internet and found a clue. Now I simply sort it out as follows:
Now you can tell that the guy who gave me the script probably wrote it on the windows platform. Use the vim-b command to view the contents of the file as follows:
Is there an extra ^ M per line?
So the next step is to find out what this ^ M is?
Long long long ago. Old teletypewriters use two characters to start a new line. One character moves the slider back to the first position (called enter, ASCII code 0D), and the other character moves the paper up one line (called newline, ASCII code 0A). When computers were invented, memory used to be very expensive. Some people decide that it is not necessary to use two characters to indicate the end of a line. UNIX developers decided that they could use one character to represent the end of a line, and Linux follows Unix, too. Apple developers prescribe the use of. The guys who developed MS-DOS and Windows decided to stick with the old-fashioned ones.
Because MS-DOS and Windows are carriage returns and newline breaks, use Vim under Linux to view the code written in VC under Windows. The "^ M" symbol at the end of the line indicates the newline character.
There are three basic solutions:
1. Replace with vim editor
Vim-b filename
Execute% s / ^ M / / g in command mode to replace
Note: the "^ M" character on the above command line is not "^" plus "M", but is generated by the "Ctrl+v" and "Ctrl+M" keys.
two。 Use the dos2unix command for conversion
Dos2unix is installed by default in some versions of the system.
In Linux, text files use "\ n" to indicate carriage return line feeds, while Windows uses "\ r\ n" to indicate carriage return line feeds. So text files that use Windows in Linux often have errors. To avoid this error, Linux provides commands for converting two text formats to each other: dos2unix and unix2dos,dos2unix convert "\ r\ n" to "\ n", and unix2dos converts "\ n" to "\ r\ n".
The commands dos2unix and unix2dos are very simple to use in the format: dos2unix filename
If you want to know more, you can check the manual. Man dos2unix
3. Use text processing tools
Cat filename | tr-d "/ r" > newfile remove ^ M and generate a new file.
There are also sed commands, etc., any commands that can be replaced can be used to generate a new file.
Besides, a. The conversion can also be completed through notepad++ tools on the windows platform. Refer to Baidu experience http://jingyan.baidu.com/article/9f63fb91d014b8c8410f0e7a.html.
b. In the process of uploading to the linux platform, you can choose the upload type to be binary, or you can avoid this problem. You can try it.
a.
b.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.