Usage of cut

Source: Internet
Author: User

1. Basic functions

Removes the specified portion from each line of the file or standard input.

2. Basic usage

Cut-[CDF] [FILE]

3. Example

$ ls-l

Total 2944

-rwxr-xr-x 1 Zach Pubs 259 Feb 1 00:12 countout

-rw-rw-r--1 zach Pubs 9453 Feb 4 23:17 headers

-rw-rw-r--1 zach Pubs 1474828 Jan 14:15 Memo

-rw-rw-r--1 zach Pubs 1474828 Jan 14:33 memos_save

-rw-rw-r--1 zach Pubs 7134 Feb 4 23:18 TMP1

-rw-rw-r--1 zach Pubs 4770 Feb 4 23:26 TMP2

-rw-rw-r--1 zach Pubs 13580 Nov 7 08:01 typescript

$ ls-l | cut-c2-10 //Display 2-10 columns

Otal 2944

Rwxr-xr-x

rw-rw-r--

rw-rw-r--

rw-rw-r--

rw-rw-r--

rw-rw-r--

rw-rw-r--

$ ls-l | tr-s ' | cut-f5,9-d '//Use the TR command to replace multiple spaces with 1 spaces, then cut shows the 5th and 9th fields (-f) with a space as a delimiter (-D).

259 countout

9453 headers

1474828 Memo

1474828 Memos_save

7134 TMP1

4770 TMP2

13580 typescript

$ cat/etc/passwd

Root:x:0:0:root:/:/bin/sh

Jenny:x:401:50:jenny chen:/home/jenny:/bin/zsh

Alex:x:402:50:alex Watson:/home/alex:/bin/bash

Scott:x:504:500:scott adams:/home/scott:/bin/tcsh

Hls:x:505:500:helen Simpson:/home/hls:/bin/bash

$ cut-d:-f5/etc/passwd //Displays the 5th field as: As a delimiter

Root

Jenny Chen

Alex Watson

Scott Adams

Helen Simpson

=-=-=-=-=
Powered by Blogilo

Usage of cut

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.