11.cat: External command
Features: Connect files and display connection results in standard output
Format: Cat [OPTION] ... [FILE] ...
Common options:
-A,--show-all: equivalent to-vet
-B,--number-nonblank: The contents of the output are numbered by row, but blank lines are not numbered
-e: Equivalent to-ve
-E,--show-ends: Displays the "$" character at the end of each line
-N,--number: A row number that is not differentiated by the contents of all outputs
-S,--squeeze-blank: Merge multiple lines of contiguous whitespace lines in a row
-T: equivalent to-VT
-T,--show-tabs: Displays tabs as "^i" characters
-V,--show-nonprinting: replace non-printable characters with "^" and "M" in addition to newline and tab stops
Exit Status:
If the command executes successfully, the status return value is 0, or if the command execution fails, the status return value is not 0.
Examples of Use:
[email protected] test]# Cat Windows.txt This is a file in Windows. From Windowsto linux OK [[e-mail protected] test]# cat-a windows.txt This was A file in windows.^m$ from Windo Ws^ito linux^m$ ok^m$
12.head: External command
Function: Displays the beginning of the file, the first 10 lines are displayed by default
Format: Head [OPTION] ... [FILE] ...
Common options:
-C,--bytes=[-]k: Displays the number of bytes of the first k in each file, and if "-" is used, it displays everything except the last K number of bytes in the file.
-N,--lines=[-]k: Displays the number of rows for the first k number of each file, rather than the first 10 lines of the file, and if you use "-", all the contents of the file except for the last number of k lines.
-Q,--quiet,--silent: Never display the file name as a header format
-V,--verbose: Always display the file name as a header format
K can have multiple suffixes: b, KB, K, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, for subsequent units T, P, E, Z, Y and so on. Use.
Exit Status:
If the command executes successfully, the status return value is 0, or if the command execution fails, the status return value is not 0.
Examples of Use:
[email protected] test]# cat file1 testend This is a test file hehe [[email protected] test]# Head-n 1 File1 testend [[email protected] test]# head-n-1 file1 testend This is a test file [[email protected] t est]#
13.tail: External command
Function: Outputs the section at the end of the specified file
Format: tail [OPTION] ... [FILE] ...
Common options:
-C,--bytes=k: The last K bytes of the output file, if +k is used, starts from the first K bytes of the file
-F,--follow[={name|descriptor}]: Tracks changes to the specified file, does not exit after output, and continues to monitor file changes
-F: Equivalent to the combination of--follow=name and--retry
-N,--lines=k: The last K line of the output file, if +k is used, starts from the file's K-line
-S,--sleep-interval=n: With the-f option, delay N seconds during two repeat checks.
Exit Status:
If the command executes successfully, the status return value is 0, or if the command execution fails, the status return value is not 0.
Examples of Use:
[[email protected] test]# cat windows.txt I AM in Windows now-a file of Windows there is a Tabhere OK end [[email protected] test]# Tail-n 2 windows.txt There is a tabhere ok end [[email protected] test]# Tail-n +2 windows.txt A file of Windows there is a tabhere ok end [[email protected] test]#
14.more: External command
Function: Using the monitor to display the file's intensive filtering program
Format: More [options] file [...]
Common options:
-num: Number of rows displayed at one time
-D: Display below the screen [press space to continue, ' Q ' to quit.] To prompt the user, if the user presses the wrong key, the [press ' H ' for instructions.] Instead of the ' beep ' sound
-L: Cancel the feature that pauses when meeting special characters ^l (paper feed)
-P: Do not scroll to display each page, but first clear the screen and then display the content
C: Similar to-P, the difference is to display the content before clearing other old information
-S: A blank line that is substituted for a row when it encounters a blank line that has more than two consecutive lines
+/pattern: Searches for the string (pattern) before each file is displayed, and then starts displaying after the string
+num: starting from Num line
More than some vi-based interactive commands
H,?: View Help Tips
Space, Z, F, ^f, S: page by screen
B, ^b: Page UP, but only when viewing the file, using the pipeline is not valid
Q, Q: Exit
V: Call VI Editor for file editing operations
: F: Displays the current file name and the current line number
.: Repeat the previous command
Exit Status:
A non-0 status value is returned only if the specified error is selected, and the other condition returns a value of 0.
15.less: External command
Features: pagination displays text document content, relative to more
Format: less [option] ... [FileName] ...
Common options:
-e: After the file content is displayed, automatic exit;
-F: Force the display of special files, such as devices, directories, or binaries;
-G: Do not highlight all search keywords, display only the currently displayed keywords, to improve the display speed;
-I: ignoring case when searching
-M: show percentages similar to more commands
-N: Line number is displayed at the beginning of each line;
-O < filename: Save less output in the specified file
-Q: Do not use warning tones
-S: Compress successive empty lines into one line;
-S: Displays longer content in a single line, without wrapping the display;
-x<: Displays the tab character as a specified number of space characters.
Less also has its own interactive commands, which are generally similar to more, but not exactly the same.
/string: Search down the function of "string"
String: The ability to search up "string"
N: Repeat the previous search (with/or?). About
N: Reverse repeats the previous search (and/or?) About
B: Turn back one page
D: Turn back half a page
H: Display Help interface
Q: Exit less command
U: Scroll forward half page
Y: Scrolls forward one line
SPACEBAR: Scrolls one line
Enter: Scroll one page
[PgDn]: Flip one PAGE Down
[PgUp]: Flip one page Up
Exit Status:
A non-0 status value is returned only if the parameter file does not exist, and the other condition returns a value of 0
16.date: External command
Function: Display and set the system date and time
Format:
Date [OPTION] ... [+format]
Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]
Common options:
-D,--date=string: Displays the time description by ' STRING ' instead of the current time
-S,--set=string: Set the system time by ' STRING '
In addition to the options, the date command can support powerful format sequences:
If you need to display the date in the specified format, you can use the "+" character to connect any one of the following formats, and each "+" character can have only one format
%a: Abbreviated format of the week (SUN-SAT)
%A: Full name format of the week (Sunday-saturday)
%b: abbreviated format of the month (JAN-DEC)
%B: Full name format for month (January-december)
%c: Display date and time directly
%d: Day of January (01-31)
%d: show date directly (MM/DD/YY)
%F: Full date, equivalent to%y-%m-%d
%h: With%b
%H: Hours (00-23)
%I: Hours (01-12)
%j: The first day of the Year (001-366)
%k: Hours (0-23)
%l: Hours (1-12)
%m: Month (01-12)
%M: minutes (00-59)
%n: Next line
%p: Show local AM or PM
%r: Direct Display time (12-hour format, HH:MM:SS [ap]m)
%s: The number of seconds since January 1, 1970 00:00:00 to date
%s: Seconds (00-60)
%t: Jump grid
%T: Full time, equivalent to%h:%m:%s
%u: Week of the Year (00-53) (Sunday is the first day of the week)
%w: Day of the Week (0-6)
%W: Week of the Year (00-53) (with Monday as the first day of the week)
%x: equivalent (%h:%m:%s am| PM)
%x: Full Date (%m/%d/%y)
%y: Abbreviated year (00-99)
%Y: Full year (0000-9999)
%Z: Show time zone
These formats do not have to be remembered, only a few common ones. such as%f,%T,%Y,%m,%d,%H,%m,%s
Exit Status:
If the command executes successfully, the status return value is 0, or if the command execution fails, the status return value is not 0.
Examples of Use:
[[Email protected] test]# date Sun may 15:11:09 CST [[email protected] test]# date +%f 2016-05-22 [Email protected] test]# date +%t 15:11:49 [[email protected] test]# date +%a-d ' 2 days ago ' Friday [email Protected] test]# date +%a Sunday [[email protected] test]#
17.hwclock: External command
Function: query or set hardware clock (RTC)
Format: hwclock [function] [option ...]
Common options:
--set: Sets the hardware clock based on the time given by the--date option
-S,--hctosys: Adjusts the system time according to the hardware clock
-W,--SYSTOHC: Adjusts the hardware clock according to the system time
--SYSTZ: Set the kernel time zone and reset the system time based on the current time zone
Examples of Use:
[Email protected] ~]# hwclock--set--date= "2016/05/22 15:32:36" [[email protected] ~]# hwclock-s [[Email Prot Ected] ~]# date Sun may 15:32:44 CST 2016
18.tree: External command
Function: Display the contents of a directory using a tree-like structure list
Format: Tree [option] ... [Directory ...]
Common options:
-A: Shows those with "." or ".." The hidden file that starts with the default tree cannot be displayed when the
-D: Show only directory names
-L: Do not allow recursive querying of directory Symbolic links
-F: Each file is to be displayed with an absolute path
-X: Just stay on the current file system
-L Level: Indicates the maximum display depth for the directory tree
Examples of Use:
[Email protected] test]# pwd/test [[email protected] test]# Tree/test/test├──num.txt├──testdir │├──dir1│└──dir2└──windows.txt 3 Directories, 2 files [[email protected] test]# tree-d/test /TEST└──TESTDIR├──DIR1└──DIR2 3 directories [[email protected] test]#
This article is from the "home of the Ops" blog, so be sure to keep this source http://zhaotianyu.blog.51cto.com/132212/1775883
Basic parsing of Linux operating system (iv)--linux essential Command Anatomy (2)