-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-ansi-language:#0400;mso-fareast-language:#0400;mso-bidi-language:#0400;}-->
1. Introduction
Retrieve various types of data from the original data file, remove the header, and output it to different files named according to the data type. This sorting and formatting task is a basic part of data analysis and processing. You can use awk, grep
Tags: edit content man file File round img ChangeIntroduction to the main contents and principles of SEDSed Stream Processing Editor
SED processes one line at a time, reads a row into a row
SED does not change file content (unless redirected)
Sed
command-line format
sed [options] ' comma
/rc5.d/: S70spice-vdagentd-------------------Instance:1. Statistics TCP Connection StatusCopy the code code as follows:# Netstat-na | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '/^tcp/Filter out lines that start with TCP, "^" for regular expression usage, ... First, this is to filter out lines that start with TCP.S[]An array named S is defined, and in awk, array subscripts usually start at 1 ins
[[email protected]/]# sed ' s/user/user/g '/etc/passwd replace all user with user[[email protected]/]# sed ' s/user/#user/'/etc/passwd replace 1th user with #user, e.g. for shielding effect[[email protected]/]# sed ' s/user//'/etc/passwd replace the 1th user with an empty[[email protected]/]# sed ' s/user/1111111111111
essentially contain countless fields and access each field through the word Ge.The automatic variable, $ $, is the first column, the second column, and so on, similar to the location parameter of the shell script, and $ A represents the entire current row.In awk, two special expressions, begin and end, both can be used in the pattern, and the purpose of providing begin and end is to give the program an initial state and perform some finishing work af
Common basic usage features of Find grep sed awk under LINUXJust to make yourself a higher standard, this is the beginning of a 6-month small white advanced road!Learning Linux Basic commands these days is a bit of a crime, especially for files looking for this piece. All I want to put some of the practical parameters I think commonly used to summarize, the big G
protected] ~]# cg-c ' root ' 1.txt2[[email protected] ~]# cg-a 2-n ' root ' 1.txt1:root:x:0:0:root:/root:/bin/bashgrep sed is a matching rule that supports {1,3}, which means repeating the preceding characters 1 to 3 times. But awk belongs to a more complicated scripting language.Words, in it () and {} have special meanings, so we want to use these symbols, we need to give them out of righteousness, you ma
Common basic usage features of Find grep sed awk under LINUXJust to make yourself a higher standard, this is the beginning of a 6-month small white advanced road!Learning Linux Basic commands these days is a bit of a crime, especially for files looking for this piece. All I want to put some of the practical parameters I think commonly used to summarize, the big G
grep, sed and awk are quite useful!Gerp Find, sed edit, awk analyzes and processes it based on content.awk (keyword: analysis processing)Parsing of one line of processing awk ' condition type 1{action 1} condition type 2{action 2
operates just a copy, and then all changes are output to the screen if not redirected to a file.Sed is a very important text filtering tool, using a single line of commands or using a pipeline with grep and awk together. is a non-interactive text stream editor.(1) Three ways to call SEDUse the SED command line format as: sed
Three major text processing tools: grep, sed, awk, and grepawk1. Use grep to search for text in a file
Grep can accept regular expressions to generate output in various formats. In addition, it has a lot of interesting options.1. Search for text lines that contain a specific
: unmatched content is not displayed.
-R recursively scans files
-L only output matching file names
-L only output unmatched file names
-C: only the number of matched items is displayed.
Common examples:
Grep-I 'root'/etc/passwd case-insensitive display file contains root lines
Grep-V '^ root'/etc/passwd: The switch is not root or line
Grep-N 'root'/etc/passwd:
grep (keyword: intercept) text-gathering tool, combined with regular expression is very powerfulMain parameters []-C: Output only matching rows-I: Case insensitive-H: Do not display file names when querying multiple files-L: Only file names with matching characters are output when querying multiple files-N: Displays matching line numbers and rows-V: Displays all lines that do not contain matching text (I often use the remove
1. How can I print out a line with a user UID greater than 500 in/etc/passwd?Awk-f ': ' $ > ' passwd2. What does NR,NF two variables mean in awk? Awk-f ': ' {print $NR} '/etc/passwd will print out what results?NR is the number of rows NF is the number of segmentsPrints the 1th paragraph of the first row, the 2nd paragraph in the second row, the 7th segment of Lin
'/test/{print $ test-----If the record contains a regular expression test, the first field is added 10 and printed out.
$ awk ' {print ($ > 5? "OK" $: "Error" ($)} ' test-----If the first field is greater than 5, the expression value after the question mark is printed, otherwise the expression value after the colon is printed.
$ awk '/^root/,/^mysql/' test---- Prints all records in the rang
'/[:::]1[1-2][:/:]/p ' datafile6. Add three asterisks (* * *) to the line starting with Fredsed-e ' s/^fred/***fred/' datafile7. Replace the row containing Jose with Jose has retiredsed-e ' s/^jose.*/jose has retire/g ' datafile8. Change Popeye's Birthday to 11/14/46Cat datafile | grep Popeye | sed-e ' s/3\/19\/35/11\/14\/46/'9. Delete all blank linessed-e '/^$/d ' datafile10. Write a script that will:. In
:
function
Description
Index (string1, string2)
Returns the position of the first occurrence of string2 in string1
Length (String)
Returns the length of a string
Match (STRING,REGEXP)
Returns a string that conforms to the regexp substring
Split (String,array,seperator)
Separates string strings into multiple fields according to the delimiter Seperator, and stores them in an array of arrays
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.