icepp的博客
icepp · 共 13 篇文章
FC配置yum源为本地光驱
###/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 -Cluster…
2009-03-17 11:13 · Linux · 评论(0)
学习java的正则表达式
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 = Pattern.compile("[a-z]{3}"); // Matcher m = p.matcher("fgh"); /…
2009-03-10 03:05 · 正则表达式 · 评论(0)
linux常用的一些小工具
xargs 这是给命令传递参数的一个过滤器, 也是组合多个命令的一个工具.它把一个数据流分割为一些足够小的块, 以方便过滤器和命令进行处理. 由此这个命令也是后置引用的一个强有 力的替换. 在一般使用过多参数的命令替换失败的时候,用xargs 来替换它一般都能成功. 通常情况下, xargs 从管道或者stdin中读取数据, 但是它也能够从文件的输出中读取数据. xargs的默认命令是 echo. 这意味着通过管道传递给xargs的输入将会包含换行和空白, 不过通过xargs的处理, 换行和空白将被空格取代. ls | xargs -n 8 echo 以每行8列的形式列出当前目录下的所有文件…
2009-03-01 14:59 · Linux · 评论(0)
对Sed1line中一些命令的理解 五
# 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 space中第一行的内容,并读入下一行,并抑制默认输出 第二…
2009-03-01 11:57 · Shell · 评论(0)
对Sed1line中一些命令的理解 四
# 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命令的man If 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 label is omitted, branc…
2009-03-01 11:36 · Shell · 评论(0)
对sed1line中一些命令的理解 三
# 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. = Print the curr…
2009-03-01 11:18 · Shell · 评论(0)
对sed1line中一些命令的理解 二
# 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 : blank 先执行x,此时 pattern space: blank…
2009-03-01 10:54 · Shell · 评论(0)
对sed1line中一些命令的理解 一
先热身一下,选一个sed1line中比较复杂点的命令 # reverse each character on the line (emulates "rev") #反转一行中每个字符的顺序(类似"rev") sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' 我们选取一行文字是 123 那么执行后模式空间中的内容应该按下边的顺序变化 处理第一行的时候,行中存在”\n”,不匹配/\n/!G; G命令不执行,得 123\n 然后执行s/\(.\)\(.*\n\)/&\2\1/; &代表s中的整个正则表达式内容 得 123\n23\n1 执行//D 23\n…
2009-03-01 10:32 · Shell · 评论(0)
常用的sed单行命令
节选自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/[ \t]*$//' # 将每一行中的前导和拖尾…
2009-03-01 09:40 · Shell · 评论(0)
unix-center中的环境配置
.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 Icepp ***" echo "*** Welcome to my linux wor…
2009-03-01 09:06 · Linux · 评论(0)
各种工具之正则表达式语法比较
在各种常用的工具中, 正则表达式如此的相似却又不同。 下表列出了一些常用的正则表达式,以及其不同之处。 项目总多,遗漏必有不少,请各位看官不吝指出。 以perl的正则为基准,不同的用法以粉红色标出。 grep 2.5.1 egrep 2.5.1 sed 3.02 sed 4.07 awk 3.1.1 perl 5.8.0 vim 6.1 JavaScript ?? 转义 \ \ \ \ \ \ \ 行头 ^ ^ ^ ^ ^ ^ ^ 行尾 $ $ $ $ $ $ $ n个 {n} {m,n} {m,} {,n} \{n\} {n} \{n\} {n}或\{n\} 仅定义 --posix 或 -…
2009-02-28 21:26 · Shell · 评论(0)
Sed基础二
Sed的高级命令,按照《o’reilly sed and awk》分法,分成如下三组:(本文很多例子也出自这本书) 一 处理多行模式空间(N D P) 二 采用保持空间来保存模式空间的内容并使它可用于后续的命令(H h G g x) 三 使用分支和条件指令更改脚本的控制流(: b t) Sed脚本中, 正常的控制流是:一行被读入模式空间并且用脚本的每个命令逐个地应用于那一行,当到达脚本的底部时,输出这一行并且清空模式空间,然后新行被读入模式空间,控制被转移到脚本的顶端。 在这里, 我们将改变脚本控制流,按照我们的预期来执行。 第一部分 N D P命令 N命令: 多行N命令通过读取新的输入行,…
2009-02-28 19:15 · Shell · 评论(0)
sed基础一
Sed是一种面向字符流的编辑器。处理文件时,sed把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾,一次只处理文件中一行的拷贝。文件内容并没有改变,除非你使用重定向存储输出。 Sed同时维护着模式空间(pattern space)和保持空间(hold space),可以将模式空间的内容复制到保持空间并在以后检索它们。 调用sed命令有两种形式 sed [options] 'command' file(s) sed [options] -f scr…
2009-02-28 13:31 · Shell · 评论(0)