Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the different functions of Linux system #

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you what the different functions of Linux system # are, the content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1.purpose! [purpose]: used to "specify which interpreter will execute the script". In Unix, anyone who is #! Annotated, all are the paths of the loader (interpreter). For example: #! / bin/bash (with no spaces in the middle) means passing all the following characters to the / bin/bash interpreter.

[common]:

#! / bin/lua

#! / bin/perl

#! / bin/python3

#! / usr/bin/env python3

#! / bin/tcl

[note]: it must be specified on the first line to take effect:

# / usr/bin/python3 print ("hello #!") Invalid 1:

# / usr/bin/python3 print ("hello #!") Invalid 2:

# invalid #! / usr/bin/python3 print ("hello #!") 2.The difference between #! / usr/bin/env python3 and #! / usr/bin/python3:

Strictly specify the path and tell OS to invoke the python3 interpreter under / usr/bin when executing the script.

#! / usr/bin/env python3: (recommended) to prevent OS-user from installing python3 in the default / usr/bin path. When the system sees this line, it will first look up the installation path of python3 in the env settings, and then call the interpreter program under the corresponding path to complete the operation.

3. Specify the interpreter in the terminal and use #! Specify [Code content] hello.py in (1) Terminal:

Print ("hello console") [execution]

Python3 hello.pypython3 specifies the interpreter in the terminal, and this is how we execute hello.py.

And this won't work: [other features]: ignore suffixes

(2) use #! Specify [Code content] hello.py:

#! / usr/bin/python3 print ("hello #!") [execute]: chmod + x hello.py gives executable permission before it can be executed directly.

[other features]: ignore suffixes

(3) the priority console specifies a higher priority.

[code content] hello.py:

#! / usr/bin/python3 print "hello #! print" hello #! " Is python2-specific syntax, Python3 execution will report an error.

[execution]

This just shows that after the terminal assigns the interpreter, #! This trade will just skip it.

The above is what are the different functions of Linux system #? have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report