◆ Shell Basics 1. view the available shell2 on the computer by using catetcshells. write a shell and save it as firstscript! BinbashThisisatestecho-n
◆ Basic Shell knowledge
1. cat/etc/shells
View the available shell on the computer
2. write a shell and save it as firstscript.
#! /Bin/bash # This is a test. echo-n Your current directory is: pwdecho $ HOMEecho Your current directory is: pwd # END.
3. run firstscript
$/Bin/bash firstscript
If the file cannot be found, use pwd to view the current directory.
$/Bin/bash pwd/firstscript
The current running result is displayed.
4. you can modify firstscript to execute
$ Chmod a + x firstscript
Enter $./firstscript.
The above shell is not exchanged, so we can interact as follows:
#! /Bin/shecho-n Please input your ID: read id_varecho-n Please input your password: read passwordecho User ID = $ id_varecho password = $ passwordif [$ password = "admin"]; thenecho "password is right" elseecho "password is wrong" fi
Run the same command as before and test it by yourself.
◆ Meaning represented by the "" and "--" symbols in the command line
If the row ends, it indicates that the row is not over yet. the following line means the same as the row.
-- Is the start of the option. Generally, the option of a letter starts with-, and the option of multiple letters starts.
"" May be omitted if it is a carriage return without line breaks, but it cannot be omitted if it is another character.
"" Tells the system that the character followed is the original intent, not a command. for example, if a file name contains spaces, add "" before the space.