Cut (Unix)
From DssWiki
{{DISPLAYTITLE:{{#if:|:|}}cut (Unix)}}
cut is a Unix command line utility which is used to extract sections from each line of input—usually from a file.
Extraction of line segments can typically be done by bytes (-b), characters (-c), or fields (-f) separated by a delimiter (-d — the tab character by default). A range must be provided in each case which consists of one of N, N-M, N- (N to the end of the line), or -M (beginning of the line to M).
[edit] Examples
Assuming a file named a containing the lines:
foo:bar:baz:qux:quux one:two:three:four:five:six:seven alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
To output the fourth through tenth characters of each line:
% cut -c 4-10 a
This gives the output:
:bar:ba :two:th ha:beta
To output the fifth field through the end of the line of each line using the colon character as the field delimiter:
% cut -d : -f 5- a
This gives the output:
quux five:six:seven epsilon:zeta:eta:teta:iota:kappa:lambda:mu
[edit] See also
[edit] External links
|SUS|default}}|cu|cut|url}} cut{{#if:{{Man/{{#if:SUS |SUS|default}}|cu|cut|display_section}}|({{Man/{{#if:SUS |SUS|default}}|cu|cut|display_section}})}}]{{#if:cut out selected fields of each line of a file|: cut out selected fields of each line of a file}}{{#if:{{#ifeq: |inline||{{Man/{{#if:SUS |SUS|default}}|cu|cut|attrib}}}}| – {{#ifeq: |inline||{{Man/{{#if:SUS |SUS|default}}|cu|cut|attrib}}}}}}
|Linux|default}}|1|cut|url}} cut{{#if:{{Man/{{#if:Linux |Linux|default}}|1|cut|display_section}}|({{Man/{{#if:Linux |Linux|default}}|1|cut|display_section}})}}]{{#if:remove sections from each line of files|: remove sections from each line of files}}{{#if:{{#ifeq: |inline||{{Man/{{#if:Linux |Linux|default}}|1|cut|attrib}}}}| – {{#ifeq: |inline||{{Man/{{#if:Linux |Linux|default}}|1|cut|attrib}}}}}}
{{#if: |
Unix command line programs and builtins (more) | |||
| File and file system management: | cat | chattr | cd | chmod | chown | chgrp | cksum | cmp | cp | du | df | file | fsck | fuser | ln | ls | lsof | mkdir | mount | mv | pwd | rm | rmdir | split | touch | ||
| Process management: | at | chroot | crontab | exit | kill | killall | nice | pgrep | pidof | pkill | ps | sleep | time | top | wait | watch | ||
| User Management/Environment: | env | finger | id | mesg | passwd | su | sudo | uname | uptime | w | wall | who | whoami | write | ||
| Text processing: | awk | comm | cut | ed | ex | fmt | head | iconv | join | less | more | paste | pg | sed | sort | tac | tail | tr | uniq | wc | xargs | ||
| Shell programming: | basename | echo | expr | false | printf | test | true | unset | Printing: | lp |
| Communications: inetd | netstat | ping | rlogin | traceroute | Searching: find | grep | strings | Miscellaneous: banner | bc | cal | dd | man | size | yes | |
