[Shell] 把连续多个空格变成单个空格
把连续多个空格变成单个空格的几个方法:[root@oracle6 ~]# echo "a b c d" | sed 's/[ ][ ]*/ /g'a b c d[root@oracle6 ~]# echo "a b c d" | awk '{$1=$1;print}'a b c d[root@oracle6 ~]# echo "a b &...
[Shell] awk 实现列转行例子
awk 实现列转行例子(收藏下)[/tmp/test]# cat tt31 2 3 4 5 6 72 3 4 5 6 7 13 4 5 6 7 1 24 5 6 7 1 2 35 6 7 1 2 3 4[/tmp/test]# awk '{maxnf=NF;maxnr=NR;for(i=1;i<=NF;i++) a[NR,i]=$i}END{for(i=1;i<=maxnf;i++){for(j=maxnr;j>=0;j--) printf a[j,i]" ";printf "\n"}}' tt35 4 3 2 1 6 5 4 3 2 &...
[Shell] awk 数组(2)
参考http://bbs.chinaunix.net/thread-2312439-1-1.html1.建立数组array[index] = value 数组名array,下标index以及相应的值value。[/tmp/test]# awk 'BEGIN{a[1]="a";a[2]="b";for(i in a)print i"="a[i]}'2=b1=a2.读取数组[/tmp/test]# awk 'BEGIN{a[1]=1;a[2]=2;a[3]=3;for(i in a)print i"="a[...
[Shell] awk $1=$1
$1=$1 是用来激活$0的重新赋值,也就是说 字段$1...和字段数NF的改变会促使awk重新计算$0的值,通常是在改变OFS后而需要输出$0时这样做 echo "A B C D" | awk '{OFS="|";print $0;$1=$1;print $0;}' A B C D A|B|C|D 即使OFS放在BEGIN里,也没有用 ...
[Shell] awk 统计分组数据
论坛上看到的统计数据的例子,自己测试一下.http://bbs.chinaunix.net/thread-4244399-1-1.html0.2 0.3 0.5 10.3 0.1 0.2 30.4 0.2 0.3 10.2 0.2 0.2 20.3 &nb...
[Shell] get after|before year,month,day,week,hour,minute,second
year[root@oracle ~]# date;date -d "1year"Tue Mar 8 23:45:18 CST 2016Wed Mar 8 23:45:18 CST 2017[root@oracle ~]# date;date -d "-1year"Tue Mar 8 23:45:25 CST 2016Sun Mar 8 23:45:25 CST 2015month[root@oracle ~]# date;date -d "-1month"Tue Mar 8 23:46:44 CST 2016M...
[Shell] awk-合并文本内容(join)
在论坛上看到的问题,记录下[/tmp/test]# cat tt6aa 1 2bb 2 3cc 3 4[/tmp/test]# cat tt7aa 2 1bb 8 2cc 4 4dd 5 5想将tt6,tt7内容合并为cc 3 4 4 4aa 1 2 2 1bb 2 3 8 2最开始想到到awk将两个文本的内...
[Shell] awk 数组(1)
在论坛上看到的问题,将tt6中的第三列的内容替换为tt5中的内容,关联列是tt5的第一列和tt6的第六列[/tmp/test]# cat tt5 Z82004A 70Z82004B 70Zxxxb 70Z7D009B 70ZKH919C ...
[Shell] awk 去除文本的第一行和最后一行
在论坛上看到了关于awk的例子,记录下来awk 去除文本的第一行和最后一行[/tmp/test]# cat tt2 | grep -n ""1:555-05422:555-12343:555-16754:555-21275:555-29126:555-34127:555-34308:555-55539:555-648010:555-669911:555-768512:555-8971[/tmp/test]# cat tt2 | awk 'NR>2{print p}{p=$0}' &nb...
[Shell] awk学习(4)-read input file
NR,FNR,NF的定义在 http://blog.itpub.net/24237320/viewspace-2072968/FS,OFS,RS,ORS的定义在 http://blog.itpub.net/24237320/viewspace-2062456/下面为其他的情况或者例子1.更改field后,print内容会有发生变化[/tmp/test]# awk '{print $2;$2=$2-10;print $0}' ff2 #$2发...
[Shell] Monitor other host oracle instance alert.log and mail
自己写的每隔一分钟检测其他other hosth上的oracle instance的alert.log文件是否有错误,如果有错误,则mail出来。有很多地方没有考虑到以后多加改善1.other host's script[mon@oracle source]$ more mon_alert_log #!/bin/bashalertlog=/u01/oracle/diag/rdbms/yangxu/yangxu/trace/alert_yangxu.logdatetime=`dat...
9.Monitor other host oracle instance alert.log and mail
自己写的每隔一分钟检测其他other hosth上的oracle instance的alert.log文件是否有错误,如果有错误,则mail出来。有很多地方没有考虑到以后多加改善1.other host's script[mon@oracle source]$ more mon_alert_log #!/bin/bashalertlog=/u01/oracle/diag/rdbms/yangxu/yangxu/trace/alert_yangxu.logdatetime=`dat...
svchost.exe占用很高的内存
笔记本重新重装系统后,开启机器没有多久后,svchost.exec占用很高的内存baidu后发现服务中关闭superfetch服务后svchost.exe占用的内存降了下来。没有过多久svchost.exec又占用很高的内存之后关闭Windows update服务后(禁止服务启动),内存使用率降了下来...
[Developer] Grouping sets
grouping setsgroup by grouping sets(a,b,c) = group by a union all group by b union all group by cSQL> list 1 &nb...
[Shell] awk学习(3)-regular expression 正则表达式
A regular expression is used as a pattern by enclosed it in slashes.^ :this matches the begining of a string (awk '/^J/' ff2 :以J开头) $ :this matches only at the end of the string (awk '/7$/' ff2:以7结尾). &nb...
[Developer] Cube
cube(a,b) 统计列包含:(a,b)、(a)、(b)、()cube(a,b,c) 统计列包含:(a,b,c)、(a,b)、(a,c)、(b,c)、(a)、(b)、(c)、()……以此类推ing……cube分组级别更多,结果更精细 SQL> editWrote file afiedt.buf 1 select b.dname,a.job,sum(sal) 2 from emp a,d...
[Shell] awk学习(2)-pattern{action}
其中如果pattern为true,则执行action其中关系运算符包括>,<,==,!=,~,!~ #~表示match,!~表示不match例子:[/tmp/test]# more tt11A125 Jenny 100 210A341 Dan 110 215P158 Max 130 209P148 John 125 220A123 Li...
[HP-UX] vxfs mount:xxxx is corrupted.needs checking
HP-UX 小机重启后,mount lvm的时候出现了如下错误[root@xxxxx002:/]# mount /dev/vgXXXX/lvol1 /oradata/XXXX/data4vxfs mount: /dev/vgXXXX/lvol1 is corrupted. needs checking执行fsck命令进行检查[root@xxxxx002:/]# fsck -F vxfs /dev/vgXXXX/lvol1log replay in progressreplay complete - marking super-bl...
[Shell] awk学习(1)-pattern{action}
awk pattern{action}其中如果pattern为true,则执行action样例data file[/tmp/test]# cat ff1aardvark 555-5553 1200/300 Balpo-net 555-3412 2400/1200/300 Abarfly 555-7685 1200/300 Abites 555-1675 2400/1200/300 Acamelot 555-0542 300 Ccore 555-2912 1200/300 Cfooey 555-1234 2400/1200/300 Bfoot 555-...
[Developer] Procedure发送html形式表格的mail
如下procedure先生成html格式的样式,然后利用sendmail procedure 发送邮件出来。create or replace procedure mon_filesystem_proasv_body long;v_subject varchar2(1000) :='Filesystem Warning';msg varchar2(1000);cursor c1 is SELECT hostname,filesystem,allbytes,usebytes,freebytes,usepct,mou...