文章列表
new ValueFilter(
CompareOp.LESS,
new BinaryComparator(Bytes.toBytes("a"))
);
new QualifierFilter(
CompareOp.NOT_EQUAL,
new BinaryPrefixComparator(Bytes.toBytes("Column"))
);
new RowFilter(
CompareOp.EQUAL,
new SubstringComparator("KEY1")
);
new RowFilte ...
1.用shell求出从1至100的累加和
echo |awk '{for (i=1;i<=100;i=i+1) a=a+i} { print a}'
2.输出1到1000中能被7正常的数到/home/johnny中,并在屏幕中输出这些数之和!
#!/bin/sh
sum=0
for a in `seq 1 1000`
do
if [ `expr $a % 7` -ne 0 ]
then
continue
fi
echo $a>>/home/johnny/print
sum=`expr $sum + $a ...
grep命令练习
文件:datafile
Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300
Betty Boop:245-836-8357:635 Cutesy Lane, Hollywood, CA 91464:6/23/23:14500
Igor Chevsky:385-375-8395:3567 Populus Place, Caldwell, NJ 23875:6/18/68:23400Norma Corder:397-857-2735:74 Pine Street, Dearborn, ...
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
my @array = ( 'a', 'b', 'c', 'a', 'd', 1, 2, 5, 1, 5 );
my %saw;
my @out=grep(!$saw{$_}++,@array);
print "@out\n";
如下文本:
12
23
34
45
56
67
想要得到的结果:
1223
3445
5667
1
perl -pe "chomp if $.%2" file
2
perl -pe "chomp; $_.=<>" file
3
perl -lpe "$\=--$|?$,:$/" file
第一种解释比较好理解,奇数行chomp去掉“\n”;
第二种所有行去去掉换行符,通过连接符“.”连接读入的下一行“<>”;
第三种是最神奇的
$| 默认是为0,通过--$|实现1与0相互跳转
$, 默认是空字符串
$ ...
($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$mon++;
$mon="0$mon"
if ($mon<10);
$mday="0$mday"
if ($mday<10);
$year+=1900;
print "$year-$mon-$mday";