Filtering Specific Columns with cut  

  When working with text files, it can be useful to filter out specific fields. Imagine that you need to see a list of all users in the /etc/passwd file. In this file, several fields are defined, of which the first contains the name of the users who are defined. To filter out a specific field, the  cut  command is useful. To do this, use the  -d  option to specify the field delimiter(-d参数指定分隔符) followed by  -f  with the number of the specific field you want to filter out(-f参数指出你要过滤哪一个fields). So, the complete command is  cut -d : -f 1 /etc/passwd  if you want to filter out  the first field of the /etc/passwd file. You can see the result bellow:

[root@rhel7 ~]# 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
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:997:995:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rusky:x:1000:1000:rusky:/home/rusky:/bin/bash
[root@rhel7 ~]# cut -d : -f 1 /etc/passwd --以冒号为分隔,filter第一部分
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
avahi-autoipd
systemd-bus-proxy
systemd-network
dbus
polkitd
tss
postfix
sshd
rusky
[root@rhel7 ~]#

 或者以冒号为分隔,filter第二部分结果如下:

[root@rhel7 ~]# cut -d : -f 2 /etc/passwd
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x

Filtering Specific Columns with cut的更多相关文章

  1. Good Practices to Write Stored Procedures in SQL Server

    Reference to: http://www.c-sharpcorner.com/UploadFile/skumaar_mca/good-practices-to-write-the-stored ...

  2. 转载Quandl R Package

    Quandl R Package 通过Quandl API可以快速准确地获取宏观经济数据.(https://www.quandl.com/docs/api) 分享两个国外的优秀网站 R和Python在 ...

  3. HBase:Shell

    HBase shell commands As told in HBase introduction, HBase provides Extensible jruby-based (JIRB) she ...

  4. HBASE SHELL 命令使用

    HBASE SHELL命令的使用 在hbase shell客户端有许多的操作命令,今天回顾并且总结一二,希望和广大读者共同进步,并且悉心聆听你们的意见.在此的hbase版本是:HBase 1.2.0- ...

  5. hbase的常用的shell命令&hbase的DDL操作&hbase的DML操作

    前言 笔者在分类中的hbase栏目之前已经分享了hbase的安装以及一些常用的shell命令的使用,这里不仅仅重新复习一下shell命令,还会介绍hbase的DDL以及DML的相关操作. hbase的 ...

  6. hbase shell operate

    , start hdfs [hadoop@alamps sbin]$ ./start-all.sh This script is Deprecated. Instead use start-dfs.s ...

  7. HBase 1.2.6 完全分布式集群安装部署详细过程

    Apache HBase 是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,是NoSQL数据库,基于Google Bigtable思想的开源实现,可在廉价的PC Server上搭建大规模结构化存 ...

  8. SQL Fundamentals: Basic SELECT statement基本的select语句(控制操作的现实列)(FROM-SELECT)

    SQL Fundamentals || Oracle SQL语言 Capabilities of the SELECT Statement(SELECT语句的功能) Data retrieval fr ...

  9. What is Druid?

    Druid is a data store designed for high-performance slice-and-dice analytics ("OLAP"-style ...

随机推荐

  1. python列表、字典与csv

    在日常数据分析时最常打交道的是csv文件和list,dict类型.涉及到的主要需求有: 将一个二重列表[[],[]]写入到csv文件中 从文本文件中读取返回为列表 将一字典写入到csv文件中 从csv ...

  2. zookeeper集群一次性启动

    编写shell脚本 新建文本,命名为start-zookeeper.sh #!/bin/sh echo "start zkServer…" for i in master work ...

  3. sql编程 1

    declare emp_count number;begin select count(*) into emp_count from emp where HIOREDATE >= TO_DATE ...

  4. IE6的bug

    借鉴http://css.doyoe.com/ 问题和经验列表,里面应有尽有.写几个常见的: 1.解决IE6及更早浏览器浮动时产生双倍边距的BUG display:inline 2.如何解决IE6下的 ...

  5. PhotoShop 移动工具详解

    自动选择工具 勾选后  可以随意移动任意图层     不勾选  只适用于移动当前所选图层 Ctrl+Z 还原移动Ctrl+Alt+Z 后退一步 复制图像 Alt键+拖动 Shift+Alt+拖动   ...

  6. 织梦dede标签tags的美化教程

    我们在行dede仿站的时候,经常会遇到tags标签的调用,调用非常简单,官方有专门的调用标签,但是官方的调用是一成不变的模式,dede5.6以前的版本,基本上都是黑色相同大小的表示,而在dede5.7 ...

  7. Python数据类型list(列表)和tuple(元组)

    list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: >>> ...

  8. Scut:SocketListener 的解析

    大致浏览了一遍,Scut 的网络模型采用的是 SAEA 模型, 它是 .NET Framework 3.5 开始支持的一种支持高性能 Socket 通信的实现. 通过分析 Scut 的套接字监听控制, ...

  9. IOS--UIDatePicker 时间选择器 的使用方法详细

    IOS--UIDatePicker 时间选择器 的使用方法详细 // 主要有下面四种类型:   // 日期显示. // 日期和时间显示. // 时间显示. // 倒计时选择       // UIDa ...

  10. IOS--UIAlertView的使用方法详细

    IOS--UIAlertView的使用方法详细   // UIAlertView的常用方法 // 标准样式 UIAlertView *oneAlertView = [[UIAlertView allo ...