linux基礎只是之awk命令使用,統計最大長度

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 > myText
echo "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 }'

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章