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 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
, default is space key[[email protected] ~]# cat 1a2a3a4a5ab2b3b4b5bc2c3c4c5c[[email protected] ~]# cat 1|awk ' {print $ \ t line: "NR" \ t the row total field: " NF} ' a line: 1 The total field of the row: 5b row: 2 The total field of the row: 5c row: 3 The Total field of the row: 5 Check the row of data that is less than 10 passwd the third column, and list only the account number and the third column. Cat/etc/passwd|
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
This book is devoted to the usage of SED and awk, which is very detailed and quite good.
Chapter 4 basic operations
1. awk and SED
2. Difference between SED and Ed
Sed is an implicit
, $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
using Perl to cause 4, Perl is a more efficient development of the language, Python is not as good as Java With groovysed own use of not much, mainly used in bulk replacement inside
This place has a little trick, sed don't use default/do delimiter, too troublesome, usually I use the # number, also can use other characters, such as @ and other characters
Sed-n "S#A#B#GP" verification is not right,
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#\
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.