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