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
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
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
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
| More to page display, or search file content can use Cat XXX | grep search to do, where we all use the pipe. Next, I'll write a piece of automatic page-display program in Python instead of using the pipe manually.
#!/usr/bin/env python
import os,sys
if not sys.argv[1:]:
print "No filename input"
sys.exit (1)
Try:
fp = open (Sys.argv[1], "R")
ex
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,
The grep command is used to find files whose content contains the specified template style. If the content of a file conforms to the specified template style, the default grep command displays the column containing the template style. If no file name is specified or the given file name is "-", The grep command reads data from the standard input device.S
We often use PS | grep xxx is queried for the existence of a process, but the grep command is returned as a result by default, so that the return value of the command is 0 regardless of whether there is a process for the query.To avoid this scenario, you can use grep's-v parameter, meaning select non-matching lines (select unmatched rows).such as querying whether the cron service is runningPS |
Pipe (), communication tool between parent-child processes. Pipe has read and write at both ends, with the Int table search shows. 0-read, 1-write. One end of the process writes data to write and another process is read from the Read section. The parameter is an int array with a total of two elements that represent the state of both read and write.Close (), which is used to turn off the empty
Common grep usage and grep usageGrep Introduction
As described in the linux man file:
Grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. by default, grep prints the matching lines.In ad
First, the problem of the current directory in the specified sub-directory specified in the server for the specified time range of all containing "meritorious acquisition" of the log content 1, the specified subdirectory 1.2.3.25 .... 1.2.3.832, specify the server the server's log file name format is: Sceneserver.log. (the latter two digits of the year, two digits) (month, not enough with 0 complement, two digits) (Day, not enough with 0 complement, two digits)-(hours, not enough with 0 compleme
Grep output highlights, grep output highlights
After the grep command is executed, the "-- color = auto" parameter can be added to the output color of the terminal.
The other two methods are as follows:
1. Set environment variables:
Export GREP_OPTIONS = "-- color = auto"
2. Modify. bashrc
Alias grep and set it with
Refer to the code found on the Internet, did not expect the difference is so big, there is a project to 50GB~70GB code, 260 keywords to do scanning, need a relatively fast solution.
[gzhy@nearby stat]$ wc -l 1
234033 1
[gzhy@nearby stat]$ perl 1.pl
cost 1 seconds
zjtel : 32606
[gzhy@nearby stat]$ perl 2.pl
cost 111 seconds
zjtel : 32606
1.pl
#!/usr/bin/perl
my $time=time();
open(file,"1");
while(
2.pl
#!/usr/bin/perl
$time=time();
$count=`
Grep command, grep command-
Grep -- search for strings matching rows in the file and Output
Command path:/bin/grep
Example 1:
# Grep Default/etc/inittab
Display the rows containing the Default string in the inittab file under the/etc/directory
Example 2: case insen
C: // progra ~ 1 // tugzip // tugzip.exe ???? Representative: C: // program files // tugzip // tugzip.exe
Answer:This is a normal phenomenon. It is due to the habit of the DOS operating system. In general, the file name in DOS is 8 characters long and 3 extension characters long.If the number is less than or equal to 8, the full name is displayed. However, if the number of file names is greater than 8 characters, only the first 6 are displayed, followed by a "~" Symbol,The number "1" indicates
Grep, regular expression, and grep Regular Expression
Grep: a text search tool that checks the row-by-row matching of the target file based on the user-specified "Mode": prints the matched rows.
Pattern: filtering condition for writing regular expressions.
Regular Expression (REGEXP): A pattern written by a special character or text character. Some of these chara
We often use grep operations like Linux in database operations. The following solutions are available:
1. Run the MySQL operation in Linux and perform grep on it. However, this method cannot be used in MySQL.
$ Mysql-u me-P "use sometable; Describe tables;" | grep "user"
2. Use pager for filtering. pager is powerful and truly implements the
you use the cat command to view a large file, only one page cannot be displayed. You can use cat xxx | more to display it by page, for example, you can use cat xxx | grep search to search the content in a file. Here we use pipelines. Next, I will write a program for automatic paging display in python, instead of using pipelines manually.
#!/usr/bin/env pythonimport os,sysif not sys.argv[1:]: print "No filename input" sys.exit(1)try: fp = open(sy
fork is called to create an IPC channel from the parent process to the child process.
In Linux, pipelines are often used. for example, when you use the cat command to view a large file, only one page cannot be displayed. you can use cat xxx | more to display it by page, for example, you can use cat xxx | grep search to search the content in a file. here we use pipelines. Next, I will write a program for automatic paging display in python, instead of
Linux processes communicate in the following ways:1-"pipelines (PIPE) and named pipelines (FIFO ).2-> Message Queue3-shared memory4-"semaphores5-"signal (signal)6-"socket (sicket)
Here, let's take a look at Pipeline (PIPE ). See other articles for the famous Pipeline (FIFO.
Eg: The previously learned command cat file | grep "ABC"> file2In my opinion, the content
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.