Linux SORT,UNIQ,CUT,WC Command detailedSortThe sort command sorts the rows in the files specified by the file parameter and writes the results to standard output. If the file parameter specifies multiple files, the sort command connects the files and sorts them as a file.Sort syntax[[email protected] ~]# sort [-fbmnrtuk] [file or stdin] options and Parameters:-F : Ignores case differences, such as a and a are treated as encodings;-B : Ignores the fi
Linux Command grep, linux Command grep
Grep command: print the line matching a style in the file
Format: grep [options] pattern [filles]
Options):
Options for style control:
-E: Extended grep, egrep
-F regex-file: Get the regular expression from the file, fgrep
-I: case inse
The wc (word count) command is used to print the number of bytes, number of words, and number of lines of a file. Wc -- help can be used to view command parameters. Wc file1 displays the number of lines, words, bytes, and file names of file1 files. Wc-c file1 counts the number of bytes in file1. Run www.2cto.com
count words, "word" means a string that is split by a blank, jump, or newline character. -L Prints the length of the longest line. 2, Example[[email protected] test]# cat test5.txt1 A23 bc456 def7890 hijk[[email protected] test]# WC test5.txt 4 8 28test5.txt#4 indicated Number of rows, 8 words (words), 28 bytes.#对比-c,-m and-w differences [[email protected] test]# less test7.txt 1234567890 [[email protected] test]#
Ps and grep lookup eliminate grep self lookup and psgrep lookup eliminate
It is very convenient to use ps-def | grep to find the process. The last line will always grep itself.
$ Ps-def | grep dragonfly-frameworkdean 5273 5272 0 00:00:00 pts/5 newlisp. /dragonfly-framewo
first to third path.#echo $PATH | Cut-d ': '-f 1-3/bin:/usr/bin:/sbin:Take the path variable out, I want to find the first to third, there is a fifth path.echo $PATH | Cut-d ': '-f 1-3,5/bin:/usr/bin:/sbin:/usr/local/binPractical Example: Display only/etc/passwd users and shells#cat/etc/passwd | Cut-d ': '-f 1,7 root:/bin/bashdaemon:/bin/shbin:/bin/shWCThe number of words in the statistics file, how many lines, how many characters.WC syntax[[email protected] ~]#
first to third path.#echo $PATH | Cut-d ': '-f 1-3/bin:/usr/bin:/sbin:Take the path variable out, I want to find the first to third, there is a fifth path.echo $PATH | Cut-d ': '-f 1-3,5/bin:/usr/bin:/sbin:/usr/local/binPractical Example: Display only/etc/passwd users and shells#cat/etc/passwd | Cut-d ': '-f 1,7 root:/bin/bashdaemon:/bin/shbin:/bin/shWCThe number of words in the statistics file, how many lines, how many characters.WC syntax[[email protected] ~]#
first to third path.#echo $PATH | Cut-d ': '-f 1-3/bin:/usr/bin:/sbin:Take the path variable out, I want to find the first to third, there is a fifth path.echo $PATH | Cut-d ': '-f 1-3,5/bin:/usr/bin:/sbin:/usr/local/binPractical Example: Display only/etc/passwd users and shells#cat/etc/passwd | Cut-d ': '-f 1,7 root:/bin/bashdaemon:/bin/shbin:/bin/shWCThe number of words in the statistics file, how many lines, how many characters.WC syntax[[email protected] ~]#
variable out and I'll find the third and fifth paths.#echo $PATH | Cut-d ': '-f 3,5//sbin:/usr/local/binTake the path variable out and I'll find the third to last path.echo $PATH | Cut-d ': '-f 3-/sbin:/usr/sbin:/usr/local/bin:/usr/x11r6/bin:/usr/gamesTake the path variable out and I'll find the first to third path.#echo $PATH | Cut-d ': '-f 1-3/bin:/usr/bin:/sbin:Take the path variable out, I want to find the first to third, there is a fifth path.echo $PATH | Cut-d ': '-f 1-3,5/bin:/usr/bin:/s
first to third path.#echo $PATH | Cut-d ': '-f 1-3/bin:/usr/bin:/sbin:Take the path variable out, I want to find the first to third, there is a fifth path.echo $PATH | Cut-d ': '-f 1-3,5/bin:/usr/bin:/sbin:/usr/local/binPractical Example: Display only/etc/passwd users and shells#cat/etc/passwd | Cut-d ': '-f 1,7 root:/bin/bashdaemon:/bin/shbin:/bin/shWCThe number of words in the statistics file, how many lines, how many characters.WC syntax[[email protected] ~]#
Find file search commands in linux and grep file content search commands, grep Content Search
When using linux, you often need to find files. The search Commands include find and grep. The two commands are partitioned.
Differences(1) The find command is based onFile AttributesSearch, such as file name, file size, owner, group, whether it is empty, access time,
Grep parameter, grep
Parameters:
-? At the same time, the upper and lower lines of matching rows are displayed? Line. For example, grep-2 pattern filename simultaneously displays the upper and lower two rows of matching rows.-B, -- byte-offset: print the block number of the row before the matching row.-C, -- count: only the number of matched rows is p
~] # Cut-d 'delimiter '-f fields Options and parameters:
-D: followed by separator characters. Used with-f;-f: splits a piece of information into segments based on the-d separator, and uses-f to get the meaning of the segments;-c: take out a fixed character range in units of characters (characters;
The PATH variable is as follows:
[root@www ~]# echo $PATH/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/games# 1 | 2 | 3 | 4 | 5 | 6 | 7
Remove t
Let's introduce brieflyWC (Word Count) The function of the command is to count the number of bytes, words, and lines in the specified file, and to display the output of the statistic resultsformat: WC fileCommand parameters:- C Statistics Bytes number ( number of bytes ) , and displays the file name- L Count rows: Use line break ' \ n ' As the line end flag, which is actually a count of the number of newline characters- M The number of statistics char
The function of the WC command is to count the number of bytes, words, and lines in the specified file, and to display the output of the statistic results.Syntax: WC [options] File ...Description: This command counts the number of bytes, words, and lines in a given file. If the file name is not given, it is read from the standard input. The WC also gives the pres
1 download: http://www.vim.org/scripts/script.php? Script_id = 1, 3112. decompress the grep. Vim file to the/usr/share/Vim/vim70/plugin folder.3. Help: In the grep. Vim File Header4 usage:The following describes its usage:Vim has its own search function, but it is still a little different from the grep in shell. Sometimes when coding is in a rush, I really want t
the kernel ring output list to find ATA device information such as hard disk and optical drive
Grep-r virtualhost/etc/httpd/conf* Recursive lookup string VirtualHost
Grep-rn virtualhost/etc/httpd/conf* recursively finds the string virtualhost and finds the search target specific
Grep–color-rn virtualhost/etc/httpd/conf* recursively finds the string virtualhost a
uses-f to get the meaning of the segments;-c: take out a fixed character range in units of characters (characters;
The PATH variable is as follows:
[root@www ~]# echo $PATH/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/games# 1 | 2 | 3 | 4 | 5 | 6 | 7
Remove the PATH variable. I want to find the fifth PATH.
echo $PATH | cut -d ':' -f 5/usr/local/bin
Remove the PATH variable. I want to find the third and fifth paths.
echo $PATH | cut -d ':' -
1. WC: number of bytes, words, and lines of statistics filesformat: WC [OPTION] ... [FILE] ...Wc[option] ...--files0-from=fParameters:- C : Count bytes- M : Statistics of characters- L : Count Rows- W : Counting Words Example:[Email protected] ~]# WC abc.txt27367 abc.txt------- à ( number of lines of words bytes fil
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.