Sed and AWK getting started. Sed and AWK are text processing artifacts in * nix command lines, which are quite powerful. they are all row-oriented, or they process text in one row after another, read the content from the standard input or file, execute the script command in one row, and then print...
Sed and awk are * powerful text processing artifacts in Nix command lines. they are all row-oriented, or they process text in one row and one row. They read content from standard input or files and execute script commands in one row, then print the output to the standard output until the end of the file (EOF ).
Sed
Sed
Sed and AWK getting started. Sed and AWK are text processing artifacts in * nix command lines, which are quite powerful. they are all row-oriented, or they process text in one row and one row. They read content from standard input or files and execute script commands in one row, then print the output to the standard ou
A regular expression: a regular expression (or regular expression, called re) is a text pattern consisting of ordinary characters (such as characters A through Z) and special characters (called metacharacters). This pattern describes one or more strings to match when looking up a text body. A regular expression, as a template, matches a character pattern to the string you are searching for. Simply put, the regular expression is the method of processing the string, it is the behavior unit to cond
-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/
Linux shell sed awk command (2)-awkawk syntax Format:awk [Options]-F program-file [--] file ...Options:-F FS,--field-separator FSCreate a delimiter with FS as the input line (the default delimiter is a space or tab)-V Var=val,--assign var=valBefore executing the procedure, set a var value of Val-F program-file,--file Program-fileRead the awk instruction from the
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
) Capitalize the first lowercase letter of each word[[Email protected] sed]# sed ' s/\b[a-z]/\u/g ' test.txt3.sed the last number in a row of a file[email protected] sed]# cat Test.txtErtFff**[ABCFD]123324444[Rty]**Fgfgf[[Email protected] sed]#
Tags: awkHttp://www.cnblogs.com/ginvip/p/6352157.htmlThis is a blog I found, the content of awk is written very well, need to seeawk about! No.(1) Take odd lines[[email protected] shell]# SEQ 10 | awk ' I=!i '13579(2) Take even lines[[email protected] shell]# SEQ 10 | awk '! (i=!i) '246810(3) SEQ 10 not after 4 lines[[email protected] shell]# SEQ 10 | Head-n-4123
If you want to quickly and easily understand shell programming, here is also a simple tutorial link: http://www.ooblick.com/text/sh/There is also a little deeper Cu shell version of the town board treasure classic thirteen ask http://bbs2.chinaunix.net/thread-218853-1-1.html
If you want to quickly learn about awk and have no time to read the manual of the long e-paper, please refer to the following. If you want to study
Sed command
Sed only edits the copy of the original file in the buffer and does not change the source file. Therefore, to save the file, you must redirect it to another file.
Sed:
1. Sed [Option] 'sed command 'input file
2. Sed [O
, $3 }'
(12). Pass the value to awk in the command line
Format:
Awk command variable = input value.
For example:
DF-k | awk '($4 ~ /^ [0-9]/)/{if ($4
(13). awk Array
You do not need to define arrays before using them. Generally, you can use loops to access arrays. Format:
For (element in array) print array [element]
Sed tool Introduction
After learning about some basic applications of formal notation, what about it? Haha ~ You can play with two things, that is, sed and awk! These two guys are quite useful! For example, the logfile. Sh written by laruence analyzes the small programs in the login file, and uses and counts most of the analysis keywords. These two baby eggs are
command is only placed in a file, and the file must be! /Bin/awk-F, because this will make this file self-explanatory. Otherwise, it will not work. For ease of separation, it is best to include a file extension. awk. After writing the file, use chmod U + X to make the file executable.
//////////////////////////////////////// //////////////////////////////////////// ////////////////////////////////////////
maintained under '/dev/disk' # See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info # tmpfs/dev/shm tmpfs ults 0 0 devpts/dev/pts devptsgid = 5, mode = 6200 0 sysfs/syssysfs defaults 0 0 0 proc/procprocdefaults 0 0
③ Echo a path to sed and retrieve its directory name Through sed; for example, echo "/etc/sysconfig/" | sed, return/etcecho
Sed awk tools and some common shell scripts
(1) sed
Sed is a streamlined and non-interactive stream editor. It enters the edit command in the command line and specifies the file name, and then displays the output on the screen.
The file content read row by row is stored in the temporary buffer, which is called the pat
)Sed ' s#[^0-9a-z]# #g ' 123Swap the first and last words in the test.txt positionSed-r ' s# (^.*) (:. *:.*:.*:.*:.*:.*/.*/) (. *$) #\3\2\1#g ' Test.txtBash:x:0:0:root:/root:/bin/root (last word with first swap)Sed-r ' s# (^.*) (:. *:.*:.*:.*:.*:.*) (/.*/.*$) #\3\2\1#g ' Test.txt/bin/bash:x:0:0:root:/root:root (the last shell and the first word exchange)Sed ' s#\
/wyfs02/m02/73/49/wkiom1x5isgbnd98aacvjrggyge101.jpg "/>8.R command:the R command is a read command. SED uses this command to add the contents of a text file to a specific location in the current file. 650) this.width=650; "style=" Float:none; "title=" 27.png "alt=" wkiom1x5isgiiyizaafqdelvwzc614.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m02/73/49/wkiom1x5isgiiyizaafqdelvwzc614.jpg "/>Some special commands for 9.sed
Sed and awk
Background
When designing a script, you may need to modify the script, such as deleting or replacing some keywords. This method of dynamically modifying files during script execution is called Stream editing. A tool with stream editing capabilities is called stream editor ). Sed is a leader in this field and can complement bash's shortcomings. In addi
Sed Structure Analysis
Sed/awk provides many tutorials, most of which are examples of teaching materials, or grammar textbooks.
After learning SED and awk, the results are learned, which is easy to confuse and the syntax is easy to confuse.
This article mainly explains the s
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.