cut 命令

cut:以某种方式按照文件的行进行分割

参数列表:
 -d 自定义分隔符,默认为制表符。
 -f 与-d一起使用,field
-c --characters=LIST   select only these characters

实例: 截取文件名 和文件扩展名
echo $file | cut -f1 -d '.'

  实例: 生成随机数

[root@rhel6 test]# cat /proc/sys/kernel/random/uuid | cut -f5 -d '-'
b9eb0f0a6695
[root@rhel6 test]# echo `cat /proc/sys/kernel/random/uuid | awk -F '-' '{print $1 $2 $3 $4 $5}' | cut -c 1-8`
99e1543e


原文地址:https://www.cnblogs.com/vincenshen/p/6606546.html