Question Description: How do you deal with command-line options such as Tail-n Access.log in a Linux shell?
In bash, command line arguments can be handled in three ways, each with its own scenario.
1, direct processing, in turn to the $1,$2,..., $n, respectively, hand-handled;
2,getopts to handle the case of a single character option (such as:-N 10-f file.txt options);
3,getopt, you can handle a single char
Common Linux shell commands and shell commands
I. Basic commands
1. Shut down immediately and restart again. Execute the following command:
Shutdown-r now or reboot
2. Shut down immediately and execute the following command:
Shutdown-h now or poweroff
3. Wait for two minutes to shut down and restart again. Execute the following command:
Shutdown-r 2
4. Wait for 2
PS1 = "[\t][\u]\$"//New shell prompt shows the current time and user nameIn Windows, you often see such file paths: D:\work\FTL Moniqi\ftl_lru-0513\ftl_lru-0513\siLinux takes a different approach. Linux stores files in a single directory structure, a directory that we call virtual directories. The virtual directory contains the file paths for all storage devices installed on the PC.Linux uses the forward sl
From this beginning, it is the text content operation, which differs from the text operation.
The grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching rows. The grep full name is global Regular Expression Print, which represents the global regular expression version, and its use permissions are all users.
Shell,perl,python is a
Tags: Shell linux ops script caseIn general, case is a judgment statement that is easier to understand than if.Case Statement Formatcase in 变量 值1) 内容 ;;值2) 内容 ;;esacNote: Each content needs to be added after;; , can be written across rows or peers.
Instance: Executes the statement based on the selection entered by the user.
#!/bin/bash -# 打印选择菜单cat [Email protected] scripts]# bash case.s
Excerpt from: Abs_guide: http://www.tldp.org/LDP/abs/abs-guide.pdf
The meaning of shell variable $#,[email protected],$0,$1,$2 in Linux is explained:Variable Description:$$The PID of the shell itself (ProcessID)$!PID of the Shell's last running background process$?End code of the last Run command (return value)$-Flag at a glance using the SET comm
Linux learning-shell simple writing-shell
It is recommended that all scripts be stored in/usr/local/sbin.
Run the sh-x script. sh-x to view the execution process.
1. When using a variable in a script, use the $ symbol:
#! /Bin/bash
# Assign a value to a variable using reverse quotation marks
D = 'date + "% H: % M: % S "'
Echo "The script begin at $ d"
Echo "Now w
The first day of writing today, first of all, the basics of writing shell scripts
1. The shell script is extended with. SH, usually running./${filename}.sh or SH ${filename}.sh2. Shell script begins with #!/bin/bash #! read as "Shebang"3. Open Debugging #!/bin/bash–xv4./dev/null any thing thrown in will disappear, Linux
Linux shell compression and decompression commands, shell compression and decompression
. TarUnpack: tar xvf FileName.tarPackage: tar cvf FileName.tar DirName(Note: tar is packed, not compressed !)---------------. GzDecompress 1: gunzip FileName.gzDecompress 2: gzip-d FileName.gzCompression: gzip FileName.Tar.gz and. tgzDecompress: tar zxvf FileName.tar.gzCompres
• Execute an error after importing scripts from Windows into a Linux systemshift parameter Left SHIFT commandHow to use functions in shellshell script Combat: MySQL automatic backup and automatic decompression zip file scriptError after importing script from Windows to Linux systemLinux and Windows line break issuesUsing the Dos2unix toolDos2unix Filename=====================================================
The Linux shell is much more powerful in programming than in Windows batching, whether in loops or operations. There is no comparison of data types. The following is a summary of how an individual operates on an array while in use.
1. Array definition
[Chengmo@centos5 ~]$ a= (1 2 3 4 5)
[Chengmo@centos5 ~]$ Echo $a
A pair of parentheses is an array, and the array elements are separated by a
Tags: Linux shell in parentheses operation and dimension programmingOverview of the use of parentheses in the Linux shell 本文主要介绍Linux中括号的用法,主要包含判断文件和变量。**注意事项**:中括号两边必须有空格。The knowledge involved in using brackets , | | | 在本文对文件或者变量做判断的时候,可能会多次使用到和||这两个符号,所以在我们进
Linux-shell basics-shell
1: The user's shell History commands are saved in home/username/. bash_history
#!!
Execute the user's previous command
#! Pw
The last command starting with pw in the execution history
2: '*' to match zero or multiple characters
'? 'Match one character
# Ls-d Day * lists directories with names s
man page (man-pages)
Under Windows, we often call the Help manual an ebook, a CHM file. The Help manual below Linux is generally called man-pages. They are stored in some Linux folders in a certain way, if you need to check, you can access the Man-pages Manual index, Common: Info,man (this article is mainly about), Xman and so on. Speaking of which, there must be a friend who would say: "Is it convenient
This article is in the study of "with the old boy learning Linux Koriyuki Shell Programming Practical" the knowledge points recorded in this book. I have benefited greatly from reading this book, but this is only my personal opinion. Now let's get to the bottom of the shell script.The shell itself is a command interpre
This article is also the second of the book note in Chapter 4 Basic shell programming of learning the bash shell 3rd edition, but we will not limit it to this.
String operation
In the following description, ":" Can be deleted. "Yes" means "exist but cannot be null". ":" means "exist ", this parameter can be left blank:
$ {
Varname
:-
Word
}
: If varname exists and is not null, the value of varname is retu
Linux series-shell learning notes (Continued 1) process user input,-shell learning notes
1. Run the program with Parameters
$0 indicates the program name, $1 indicates the first parameter, $2 indicates the second parameter, and so on until the ninth parameter $9
# Vi factorial
#!/bin/shf=1for((i=1;iTest:
[root@master test]# ./factorial 5120
NOTE: If there are
the last deletion
Ctrl+d: Deletes the letter where the cursor is located; Note the difference between backspace and ctrl+h, these 2 are the characters before the cursor is deleted
CTRL+F: The cursor moves right
Ctrl+z: Move the current process to the background and use the ' FG ' command to recover. Like Top-d1 and then ctrl+z, to the backstage, then FG, and back
ESC Combination
Esc+d: Delete A word after the cursor
Esc+f: Jump Right One word
Esc+b: Jump to the left one word
Esc+t: Two
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.