linux基礎只是之awk命令使用,統計最大長度
阿新 • • 發佈:2019-02-07
awk [-F field-separator] 'commands' input-file(s) 其中,commands 是真正awk命令,[-F域分隔符]是可選的。 input-file(s) 是待處理的檔案。 在awk中,檔案的每一行中,由域分隔符分開的每一項稱為一個域。通常,在不指名-F域分隔符的情況下,預設的域分隔符是空格。
scan 'shortUrl',{COLUMN=>['su:customerId','su:postId'], LIMIT=>10}
echo "scan 'foo'" | ./hbase shell > myTextecho "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell | grep "^ " > registration.txt
scan 'shortUrl',{COLUMN=>['su:customerId','su:postId'], LIMIT=>10}
echo "scan 'shortUrl',{COLUMN=>['su:customerId','su:postId'], LIMIT=>10}" | ./hbase shell > myText
echo "scan 'shortUrl',{COLUMN=>['su:customerId','su:postId']}" | ./hbase shell > myText
awk '{print $1,substr($4,7)}' file | awk '{if (NR%2==0){print " "$2} else {printf $0}}'
awk '{print $1,substr($4,7)}' myText | awk '{if (NR%2==0){print " "$2} else {printf $0}}' > myText2
統計檔案中所有行中某個欄位的最大長度:
cat GIWEB_20150123131134_046_001150url4.dat |awk '{if (length($1)>maxlength) maxlength=length($1) ; print NR,$1,maxlength,length($1) }; END {print maxlength }'