Article Title: Dialog UNIX: full introduction to fish. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Friendly Interactive Shell (fish) is suitable for beginners and experts in UNIX
Friendly Interactive Shell (fish) is easy to use. Its syntax, context-related help, and color-coded command line interface (CLI) significantly simplifies UNIX? To reduce the burden on Script Programming.
English is a confusing language. For example, consider moon and good. For outsiders, the two words should be rhyming, but the former Pronunciation is/mun/(according to International Pronunciation Alphabet), while the latter Pronunciation is/good /. It seems that the only rule in English is an exception.
UNIX shell is also confusing. For example, in the Bourne shell (and most commonly used UNIX shells), '$ var', "$ var", and' $ var' look similar, but they produce very different results. (In the shell example in this article, the name and command number of the shell used are added before each CLI ).
bash-1) # Demonstrate the differences between single-, double-, and back quotesbash-2) var=lsbash-3) echo '$var'$varbash-4) echo "$var" lsbash-5) echo `$var`Rakefile app bin components config db doc lib log patches public script src test tmp vendor |
In the preceding command sequence, set the variable var to a string of two letters (ls. In the first echo command, this variable is not interpreted in single quotes, so the text in the quotation marks is displayed as is, that is, the string $ var with four letters. In the Code in line 2, double quotation marks interpret this variable, so the result is the string ls. Finally, the reverse code interprets the variable and serves as the intermediate result of the sub-shell operation. Therefore, '$ var' generates the intermediate string ls, which is run as a shell command to generate the content list of the current directory.
Of course, these three operators (single quotes, double quotation marks, and anti-apostrophes) are valid, but just like exceptions in English, it is a headache to remember and grasp these nuances. To further prove this, what is the difference between $ var and "$ var? (Note: Assume that $ var contains spaces .)
bash-1) # Create three files and try to remove twobash-2) touch three two onebash-3) var="one two"bash-4) rm "$var"rm: one two: No such file or directorybash-5) rm $varbash-6) lsthree |
If a variable contains spaces, double quotation marks expand the variable as a parameter as is. Otherwise, any space in the variable is interpreted as a parameter separator.
Shell syntax is a headache. This is terrible because it makes CLI (one of the most powerful UNIX features) more difficult to grasp. The inconsistency above may even cause problems for UNIX veterans.
Fortunately, the appearance of fish (Friendly Interactive Shell) has changed this chaotic situation. It provides concise syntax and significantly improves the user experience. Like other shells, fish also provides redirection, shortcuts, globbing (wildcard expansion), subshell, Tab population, and variables. However, unlike other shells, fish also provides color-coded CLI, a rich command line editor, and a large number of documents.
In addition, fish provides only one way to perform any operation, which is wise. If a UNIX utility can complete a task, fish will not repeat this feature using built-in commands. For example, fish uses a system-wide application/bin/kill to terminate a process. (In contrast, Bourne shell implements its own kill version through a built-in application. You can enter/bin/kill on the prompt of The Bourne shell command to access this version ). Taking simplicity rather than flexibility as a top priority for fish significantly simplifies its use.
Next, we will install fish and experience some of its features.
Get fish
Fish is an open source project created by Axel Liljencrantz. The License protocol used is GNU General Public License, version 2. At the time of writing this article, the latest version of fish is 1.23.0, which was released in January 13, 2008.
If you use UNIX or UNIX systems (such as Linux? Or Mac OS X), it should be easy to build a fish from the source code on your system. The following is the build procedure, as shown in Listing 1:
1. download the latest source code package of the program.
2. decompress the package.
3. Go to the source code directory.
4. Configure the build.
5. Run make.
Listing 1. Build a fish from the source code
Bash-1)Wget http://www.fishshell.org/files/1.23.0/fish-1.23.0.tar.gz Bash-2)Tar xzvf fish-1.23.0.tar.gz Bash-3)Cd fish-1.23.0 Bash-4)./Configure -- without-xsel Checking if autoconf needs to be run... no Checking if autoheader needs to be run... no Checking for/usr/pkg/include directory... no ... Bash-5)Make Gcc-c-o function. o function. c ... Bash-6)Sudo make install ... To use fish as your login shell: * Add the line '/usr/bin/fish' to the file'/etc/shells '. * Use the command 'chsh-s/usr/bin/fish '.
|
If you use UNIX-like systems, configure may not need more flags. However, to minimize dependencies and make fish use the same directory structure as common shells, you can add -- without-xsel and -- prefix =/usr respectively. (If Mac OS X version 10.4 Leopard is used, you must add the parameter LDFLAGS =-liconv. If the last option is omitted on Mac OS X, the accompanying fish Utility cannot be compiled ).
In addition, if you use a popular UNIX version, you may find a pre-built binary version that can be directly installed on your system. For example, if Debian Linux is used, you can use the sudo apt-get install fish command to directly install fish. Visit the home page of the fish project to see if your system has a binary version.
[1] [2] [3] [4] Next page