In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "what are the basics of shell?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the basics of shell" article.
Shell is also a software in the operating system, which is included outside the Linux kernel and provides an interface for the interaction between the user and the kernel. At present, the most popular shell is bash shell (GUN Bourne-Again Shell). The user's command is interpreted by shell and sent to the Linxu kernel, where the shell receives the output of the system response and displays it on the screen.
1: write a shell script, vi test.shroud Hello World echo, specify what interpreter this script requires to execute the 3:Shell "Hello World!" # Bash command is used to output text to the window 2: execute the shell script into the directory where the file exists chmod + x. / test.sh# to give the script permission to execute. / test.sh# to execute the script 3:Shell variable understanding example: your_name= "wangzhi.cn" Note: There can be no space between the variable name and the equal sign: (1). The first letter must be the letter (amurz.Amurz) (2). There can be no spaces in the middle, you can use (_) (3). Punctuation (4) cannot be used. You cannot use keywords in bash (you can use the help command to view reserved keywords) example: for file in `keyword / etc` this statement can loop out the file name of the directory under / etc 4: the use of variables defines variables: your_name = "wangzhi" use variables: echo ${your_name} # it is recommended to output variables plus {} Develop a good programming habit. 5: Shell string (Note: subscript is calculated from 0) single quotation mark: str = 'This is a string' (restriction: any character in single quote will be output as is, variable cannot be output in single quote Single quotation marks cannot appear in single quotation marks) double quotes: str = "Hello, I know your are\" ${your_name}\ "!\ n" (there can be variables in double quotes String concatenation: your_name= "qinjx" greeting= "hello," $your_name "!" greeting_1= "hello, ${your_name}!" echo $greeting $greeting_1 get string length: string= "abcd" echo ${# string} # output 4 extract string string= "alibaba is a great company" echo ${string:1:4} # output liba The subscript of a string is a look-up substring starting at 0 (subscript is calculated from 1) string= "alibaba is a great company" echo `expr index "$string" is` #! / bin/bashyour_name= "wangzhi" echo ${your_name} str='This is a String'echo "single quotation mark string: ${str}" # can be written like this, the following is misled str2= "Hello I know you are\ "${your_name}\"!\ n "echo" double quote string:\ "${str2}\"\ n "greet=" Hello, ${your_name}! "echo" string concatenation:\ "${greet}\"\ n "echo" get string length:\ "${greet}\"\ n "# 0~length-1" As in java, the same echo "extract string:\" ${greet:1:4}\ "\ n" # subscript starts at 0 and calculates 4 echo "lookup substrings from 1:\ n" echo `expr index "${greet} hello" `# subscript is a 6:Shell array calculated from 1 (can store various data types Subscript starts with 0) definition: ${array name [subscript]} for example: valuen = ${array_ name [n]} use the @ symbol to get all the elements in the array For example: echo ${array_name [@]} get the array length: # get the number of array elements length=$ {# array_name [*]} # or length=$ {# array_name [*]} # get the length of a single element of the array lengthn=$ {# array_ name [n]} 7: comment
Only single-line comments-(use # for comments)
The above is the content of this article on "what are the basic knowledge of shell". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to 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.
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.