- 论坛徽章:
- 13
|
本帖最后由 ulovko 于 2012-05-25 14:16 编辑
__lxmxn__ 发表于 2012-05-25 13:30 ![]() - grep -oP '(time|id):\d+'| sed 'N;s/\n/,/'
复制代码 \t a tab character
\n a newline character
\r a carriage-r eturn character
\s matches any ™whitespaceš character (space, tab, newline, formfeed, and such)
\S anything not !\s"
\w ![a-zA-Z0-9R]" (useful as in !\w+", ostensibly to match a word)
\W anything not !\w", i.e., ![^a-zA-Z0-9R]"
\d ![0-9]", i.e., a digit
\D anything not !\d", i.e., ![^0-9]"
The "n" command will print out the current pattern space (unless the "-n" flag is used), empty the current pattern space, and read in the next line of input. The "N" command does not print out the current pattern space and does not empty the pattern space. It reads in the next line, but appends a new line character along with the input line itself to the pattern space.
The "d" command deleted the current pattern space, reads in the next line, puts the new line into the pattern space, and aborts the current command, and starts execution at the first sed command. This is called starting a new "cycle." The "D" command deletes the first portion of the pattern space, up to the new line character, leaving the rest of the pattern alone. Like "d," it stops the current command and starts the command cycle over again. However, it will not print the current pattern space. You must print it yourself, a step earlier. If the "D" command is executed with a group of other commands in a curly brace, commands after the "D" command are ignored. The next group of sed commands is executed, unless the pattern space is emptied. If this happens, the cycle is started from the top and a new line is read.
The "p" command prints the entire pattern space. The "P" command only prints the first part of the pattern space, up to the NEWLINE character. Neither the "p" nor the "P" command changes the patterns space. |
|