`
icepp
  • 浏览: 10396 次
  • 性别: Icon_minigender_1
  • 来自: 大连
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
###/etc/yum.repos.d/rhel5-local.repo [Cluster] name=Red Hat Enterprise Linux $releasever - $basearch -Cluster baseurl=file:///misc/cd/Cluster enable=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [ClusterStorage] name=Red Hat Enterprise Linux $releasever - $basearch -Cl ...
import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegularExpression { public static void main(String[] args) { // 简单认识正则表达式的概念 // p("abc".matches("...")); // p("a8729a".replaceAll("\\d", "-")); // Pattern p = Pat ...
xargs  这是给命令传递参数的一个过滤器, 也是组合多个命令的一个工具.它把一个数据流分割为一些足够小的块, 以方便过滤器和命令进行处理. 由此这个命令也是后置引用的一个强有 力的替换. 在一般使用过多参数的命令替换失败的时候,用xargs 来替换它一般都能成功. 通常情况下, xargs 从管道或者stdin中读取数据, 但是它也能够从文件的输出中读取数据. xargs的默认命令是 echo. 这意味着通过管道传递给xargs的输入将会包含换行和空白, 不过通过xargs的处理, 换行和空白将被空格取代. ls | xargs -n 8 echo 以每行8列的形式列出当前目录下的所有文件 ...
# reverse order of lines (emulates "tac") #反转文章行的顺序(类似"tac" ) sed '1!G;h;$!d' # method 1 sed -n '1!G;h;$p' # method 2   说下method1原理,method2和它类似。 h   copy pattern space to hold space.   流程如下   当读入第一行的时候,不匹配1!G,G不执行,然后执行h命令将第一行的内容copy到了hold space。不是最后一行,匹配$!d,执行d命令删除当前pattern spac ...
  # align all text flush right on a 79-column width #右对齐,按79列宽排列所有文本 sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space   t命令的manIf a s/// has done a successful substitution since the last input line was read and since the last t or       T command, then branch to label; if ...
  # number each line of a file (simple left alignment) Using a tab (see # note on '\t' at end of file)instead of space will preserve margins. #给文件每一行加上数字序号。用TAB制表符替换空间来保留空白 #(在数字序号和文本中间加一TAB制表符) sed = filename | sed 'N;s/\n/\t/'  N    append the next line of input into the pattern space. =     Pr ...
  # insert a blank line above every line which matches "regex" #在每个含有字符串regex的行上插入一行空白行 sed '/regex/{x;p;x;}'   复习下x ,p命令x   Exchange the contents of the hold and pattern spaces.P   Print the current pattern space.   脚本工作流程: 当读入匹配RE的那一行时,       pattern space:  regex      hold space :  bla ...
先热身一下,选一个sed1line中比较复杂点的命令   # reverse each character on the line (emulates "rev") #反转一行中每个字符的顺序(类似"rev") sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'     我们选取一行文字是 123 那么执行后模 ...
节选自sed1line     # 在匹配式样“regex”的行之前和之后各插入一空行 sed '/regex/{x;p;x;G;}' #删除所有偶数行 sed 'n;d' # 为文件中的每一行进行编号(简单的左对齐方式)。这里使用了“制表符” # (tab,见本文末尾关于'\t'的用法的描述)而不是空格来对齐边缘。 sed = filename | sed 'N;s/\n/\t/' # 将每一行前导的“空白字符”(空格,制表符)删除 # 使之左对齐 sed 's/^[ \t]*//' # 将每一行拖尾的“空白字符”(空格,制表符)删除 sed 's ...
.bash_profile   . ~/.bashrc      .bashrc   /* .bashrc */ # Icepp 's .bashrc # # Source global definitions # if [ -f /etc/bashrc ]; then . /etc/bashrc # --> Read /etc/bashrc, if present. fi # # Greetings # echo "*********************************" echo "*** This is Ice ...
在各种常用的工具中,正则表达式如此的相似却又不同。下表列出了一些常用的正则表达式,以及其不同之处。项目总多,遗漏必有不少,请各位看官不吝指出。以perl的正则为基准,不同的用法以粉红色标出。   grep 2.5.1 egre ...
  Sed的高级命令,按照《o’reilly sed and awk》分法,分成如下三组:(本文很多例子也出自这本书) 一  处理多行模式空间(N  D  P)二  采用保持空间来保存模式空间的内容并使它可用于后续的命令(H h G g x)三  使用分支和条件指令更改脚本的控制流(: b  t) Sed脚本中, 正常的控制流是:一行被读入模式空间并且用脚本的每个命令逐个地应用于那一行,当到达脚本的底部时,输出这一行并且清空模式空间,然后新行被读入模式空间,控制被转移到脚本的顶端。 在这里, 我们将改变脚本控制流,按照我们的预期来执行。   第一部分  N D P命令   N命令:多行N命令通过 ...
Sed是一种面向字符流的编辑器。处理文件时,sed把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾,一次只处理文件中一行的拷贝。文件内容并没有改变,除非你使用重定向存储输出。 Sed同时维护着模式空间(pattern space)和保持空间(hold space),可以将模式空间的内容复制到保持空间并在以后检索它们。 调用sed命令有两种形式 sed [options] 'command' file(s)sed [options] -f scrip ...
Global site tag (gtag.js) - Google Analytics