shell入门-cut命令
2015-11-15 15:21
357 查看
命令:cut
选项:-d:-f 指定第几段由“:(分割符)”分割的段
-c 指定第几个字符
说明:选取命令,选取一段数据中我们想要的,一般是针对每行来分析选取的
[root@wangshaojun ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
......
[root@wangshaojun ~]# cut -d: -f 4 /etc/passwd//////指定单个段
0
1
2
....
[root@wangshaojun ~]# cut -d: -f 3,1,4 /etc/passwd ////指定多个段
root:0:0
bin:1:1
daemon:2:2
.......
////////////////////////////////////////////////////////////////////////////////////////
[root@wangshaojun ~]# cut -c 10 /etc/passwd /////指定第一个字符
0
:
2
.....
[root@wangshaojun ~]# cut -c 1-10 /etc/passwd //////指定区间字符
root:x:0:0
bin:x:1:1:
daemon:x:2
......
//////////////////////////////////////////////
总结 cut 常用选项-d: -f ; -c
选项:-d:-f 指定第几段由“:(分割符)”分割的段
-c 指定第几个字符
说明:选取命令,选取一段数据中我们想要的,一般是针对每行来分析选取的
[root@wangshaojun ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
......
[root@wangshaojun ~]# cut -d: -f 4 /etc/passwd//////指定单个段
0
1
2
....
[root@wangshaojun ~]# cut -d: -f 3,1,4 /etc/passwd ////指定多个段
root:0:0
bin:1:1
daemon:2:2
.......
////////////////////////////////////////////////////////////////////////////////////////
[root@wangshaojun ~]# cut -c 10 /etc/passwd /////指定第一个字符
0
:
2
.....
[root@wangshaojun ~]# cut -c 1-10 /etc/passwd //////指定区间字符
root:x:0:0
bin:x:1:1:
daemon:x:2
......
//////////////////////////////////////////////
总结 cut 常用选项-d: -f ; -c
相关文章推荐
- shell入门-特殊符号
- shell常用命令
- shell-bash学习03 别名、日期、函数
- shell编程笔记
- shell读取文件每一行的方式
- xshell 登陆 ubuntu
- linux shell 管道命令(pipe)使用及shell重定向
- Xshell的使用
- Shell Game
- 让shell脚本在后台飞
- LinuxShell算术运算
- 如何在 Bash 中删除“除某些文件外的所有文件”?
- 正则表达式shell
- shell根据日期实现完全备和增量备份文件
- shell 自动发送邮件脚本
- XShell连接VirtualBox下的Linux虚拟机
- shell_of_brief_introduction
- shell中的tee命令的使用
- awk与cut在以空格为分割域时的区别
- Android Shellcode Telnetd with Parameters