Bash Shell Process Control -- select, bashshell
Preface today, I just wrote an automated packaging script and used bash shell again. Here we mainly want to introduce the select command, which can help us complete the menu selection function.
The format is also the first time I use select process control today. The select function is not implemented in php, Java, and C. In Bash Shell, the select format is as follows:
select $var in ${list[@]}do statements that can use $vardoneWhen the select statement is executed, the selection menu is provided based on the list array. The selected result is saved in the $ var variable and the statements Statement is executed. After the execution is complete, the menu is provided again, waiting for the user to select. If you want to skip the selection loop, you need to add the break statement in the loop body according to the conditions.
The example shows an example of select. For details, refer:
#!/bin/bashfruits=( "apple" "pear" "orange" "watermelon")echo "Please guess which fruit I like :"select var in ${fruits[@]}do if [ $var = "apple" ]; then echo "Congratulations, you are my good firend!" break else echo "Try again!" fidone
Bash shell Command
At ---- schedule, check, and delete jobs in the queue
Cat ---- connect the file and print it to the standard output
Cd ---- Change directory to be able to process absolute and relative paths
Chmod ---- change the file protection permission
Chown-change the owner and group of Files
Clear ---- clear the screen (like cls in DOS)
Cp ---- copy an object
Crontab-operate the daemon and execution schedule of each user
Date ---- print or set the system date and time
Dd ---- copy an object (and convert it at the same time)
Df ---- report the remaining disk space
Du ---- report disk space usage
File ---- test file and directory types
Find ---- search for files in a directory
Grep ---- search for matched rows in the file and Output
Gzip-compress or expand a file
Head ---- display the first few lines of the file
History ---- display historical Command records
Kill ---- abort a process
Last ---- shows how many users or terminals have logged on to the machine
Less ---- you want to use the more command to display files by PAGE
Ln ---- establish a connection Between Files
Ls ---- list files in the current directory
Man ---- display online manuals with certain formats
More ---- the command can read the text page by page
Mount ---- install a File System
Mv ---- rename the file
Passwd ---- set the User Password
Ps ---- command to list Running Processes
Reboot ---- restart the system
Rm ---- command used to delete files
Su ---- create and edit Unix archive files
Tar ---- create and edit Unix archive files
Touch ---- change the time parameter of the file
Wc ---- count the number of bytes, number of words, and number of rows in a file
Who ---- view other login users
Which ---- which -- display the full path of the command
Ping ---- command-determine whether the machine on the network can reach or reach the speed
Multi-task
Output redirection
Understanding processes
--------------------------------------------------------------------------------
In Linux, there are two operation interfaces: X Window mode (KDE by default) and Console mode (Console ). The two interfaces are similar to Windows and DOS.
If you want to change to Console mode in X Window mode, you only need to press Alt + F1 (or F2... F6) key. A new waiting window will appear on the screen. You can log on to the system again in Console mode. If you want to return to X Window mode in Console mode, press Ctrl + Alt + F7 at the same time.
If the X Window mode is not enabled and you want to start the X Window mode from the console mode, enter startx (or kdm) in the Console mode to start the X Window.
In the above two chapters, we have introduced the operation of the X Window (KDE by default). In this chapter and the next chapter, we will mainly discuss the operations in the Console mode, the corresponding KDE operation will also be inserted between them.
6.1 start and close the system
Start the system
If you have installed LILO during the installation process, you can start the system. When LILO is started, the screen displays:
LILO:
Click the Tab key to display all operating systems that can be started. Enter the name of the displayed operating system to start the corresponding operating system. Type Linux to start BluePoint Linux & 127. If you press the Enter key directly or wait for 5 seconds, you can also start the BluePoint Linux & 127; operating system.
Another way to start linux is to run the command in DOS/WINDOWS... the remaining full text>
How to Understand bash shell?
To understand bash shell, you must first understand bash and shell respectively.
Shell is a shell that serves as a bridge between the operating system (kernel) and the user. It acts as a command interpreter and translates user input commands to the system for execution. Like DOS in Windows, some built-in commands are provided for users to use. You can use these commands to write shell scripts to complete complex work.
Besides bash, there are several popular shell types: tcsh, csh, bash, and ksh. I will not talk about the differences between them here, I believe you can find relevant information on the Internet (including bash refers to the Bourne-again shell), but I would like to say that many linux distributions currently include the bash shell by default.
Reference: sername