Linux 字符串截取命令 cut
cut - remove sections from each line of files
字符操作
截取第 8 个字符
[root@production ~]# echo 1234567890 | cut -c 8 8
从第五个字符开始,截取后面的
[root@production ~]# echo 1234567890 | cut -c 5- 567890
截取第8个字符前面的字符串
[root@production ~]# echo 1234567890 | cut -c -8 12345678
从第4字符开始,截取至第8个字符为止
[root@production ~]# echo 1234567890 | cut -c 4-8 45678
每一行操作,截取位置1-4的字符
$ cat /etc/passwd | cut -c 1-4 root daem bin: sys: sync game man: $ echo "No such file or directory"|