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
本文介绍了如何利用Linux命令行工具cut来实现文件内容的分割与提取。通过具体实例展示了如何截取文件名和文件扩展名,以及如何生成随机数。
1029

被折叠的 条评论
为什么被折叠?



