1、格式化的文本内容
# head 2620.log
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:12:37,902 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/PRMSL/18082620.084"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:12:40,683 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP_CHANGE_24H/850/18082620.087"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:12:41,326 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/PRMSL_CHANGE_24H/18082620.084"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:13,859 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP/925/18082620.090"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:13,987 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/HGT/925/18082620.090"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:14,238 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/RH/925/18082620.087"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:14,238 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/RH/925/18082620.084"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:14,361 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/SPFH/925/18082620.087"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:14,639 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/VVEL_GEOMETRIC/925/18082620.087"
logs/mdfs-monitor.nwp.py.log.10:2018-08-27 01:14:15,221 - root - INFO - rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP/850/18082620.090"
2、从指定位置开始截取
# cut -c 72- 2620.log | head
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/PRMSL/18082620.084"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP_CHANGE_24H/850/18082620.087"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/PRMSL_CHANGE_24H/18082620.084"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP/925/18082620.090"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/HGT/925/18082620.090"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/RH/925/18082620.087"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/RH/925/18082620.084"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/SPFH/925/18082620.087"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/VVEL_GEOMETRIC/925/18082620.087"
rpush "filename:/nwp" "cassandra:/GRAPES_GFS/TMP/850/18082620.090"
3、截取参数说明
# cut --help
用法:cut [选项]... [文件]...
Print selected parts of lines from each FILE to standard output.
Mandatory arguments to long options are mandatory for short options too.
-b, --bytes=列表 只选中指定的这些字节
-c, --characters=列表 只选中指定的这些字符
-d, --delimiter=分界符 使用指定分界符代替制表符作为区域分界
-f, --fields=LIST select only these fields; also print any line
that contains no delimiter character, unless
the -s option is specified
-n with -b: don't split multibyte characters
--complement 补全选中的字节、字符或域
-s, --only-delimited 不打印没有包含分界符的行
--output-delimiter=字符串 使用指定的字符串作为输出分界符,默认采用输入
的分界符
--help 显示此帮助信息并退出
--version 显示版本信息并退出
仅使用f -b, -c 或-f 中的一个。每一个列表都是专门为一个类别作出的,或者您可以用逗号隔
开要同时显示的不同类别。您的输入顺序将作为读取顺序,每个仅能输入一次。
每种参数格式表示范围如下:
N 从第1 个开始数的第N 个字节、字符或域
N- 从第N 个开始到所在行结束的所有字符、字节或域
N-M 从第N 个开始到第M 个之间(包括第M 个)的所有字符、字节或域
-M 从第1 个开始到第M 个之间(包括第M 个)的所有字符、字节或域
当没有文件参数,或者文件不存在时,从标准输入读取
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告cut 的翻译错误
要获取完整文档,请运行:info coreutils 'cut invocation'
转载于:https://blog.51cto.com/dressame/2164839