单行命令工具datamash处理字符、数组
常用的单行工具有: awk,grep,sed, 三剑客天下无敌。 轻量工具摆脱切片。datamash值得拥有。 R语言中常用的对应命令工具是:dplyr或者aggregate()
datamash安装方法(2选1即可): 1.可能安装到的不是最新版本
sudo apt-get install datamash
- 源码安装 源码下载 选择适合的版本
wget https://ftp.gnu.org/gnu/datamash/datamash-1.4.tar.gz
tar -xzf datamash-1.4.tar.gz
cd datamash-1.4
./configure --prefix=~/soft/datamash
make
make check
make install
参考链接 菜鸟团
常用命令
Primary operations: groupby, crosstab, transpose, reverse, check datamash groupby Line-Filtering operations: rmdup Per-Line operations: base64, debase64, md5, sha1, sha256, sha512, bin, strbin, round, floor, ceil, trunc, frac Numeric Grouping operations: sum, min, max, absmin, absmax, range Textual/Numeric Grouping operations: count, first, last, rand, unique, collapse, countunique Statistical Grouping operations: mean, trimmean, median, q1, q3, iqr, perc, mode, antimode, pstdev, sstdev, pvar, svar, mad, madraw, pskew, sskew, pkurt, skurt, dpo, jarque, scov, pcov, spearson, ppearson
示例
可以用来检测文件的字段数是否一致,正常是0,错误是1.
cat genes.txt |datamash check && echo "0" || echo "1"