才知道,编辑器也是可以编程的!才知道,编辑器也可以是非交互的。 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/67326/showart_586075.html
本帖最后由 一棵菠菜 于 2011-10-20 10:58 编辑 [code]请教大家一 shell 问题: 当 consultant501@hotmail.com 或者 8989@hotmail.com 关键字存在时取出关键字所在行和下一行,并且当取出的第二行存在关键字 remote 时才显示第一行 9 Oct 2011 08:51:17 GMT #46858383 9084 <> remote info@cbn.org 19 Oct 2011 08:42:21 GMT #66798601 15299 <> remote info@cbn.org 19 Oct 2011 08:12:57 GMT #66...
编写awk脚本 ==================== 1. 从 Hello, World 开始 ==================== we create a file named test that contains a single line. This example shows a script that contains the print statement: $ echo 'this line of data is ignored' > test $ awk '{ print "hello, world"}' test This scripts has only a single action, which is enclosed in braces. 这个脚本只有一个动作, 被放在{}中. 这个动作是为每行...
本帖最后由 zhaolianghz 于 2016-05-12 16:57 编辑 [root@oracle10g ~]# grep ^JAVA_OPTS /opt/apache-tomcat-6.0.35/bin/catalina.sh JAVA_OPTS="-server -Xms1048m -Xmx1048m -XX:NewRatio=2 -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote " tomcat 的catalina.sh脚本,想把上面那段过滤出来,然后在末尾加上-Dapp-tomcat=aaaaa 该如何处理,grep ^JAVA_OPT...
本帖最后由 baby_神 于 2016-01-14 21:52 编辑 1、打印文件奇数行 sed -n 'p;n' sed 'n;d' sed -n '$!N;P' sed -n '1~2p' awk 'i=!i' awk 'NR%2' 2、打印文件偶数行 sed -n 'n;p' sed -n '0~2p' awk '!(i=!i)' awk '!(NR%2)' 3、打印文件倒数第二行 sed -n 'N;$P;D' awk '{a[NR]=$0}END{print a[NR-1]}' awk '{a=b;b=$0}END{print a}' 4、文件顺序倒过来(模拟tac) sed '1!G;h;$!d' awk '{a[NR]=$0}END{for(i=NR;i>=1;i--)pri...