Usage Guidelines
To use this command, you must be in a user group associated with a task group that includes appropriate task IDs. If the user group assignment is preventing you from using a command, contact your AAA administrator for assistance.
The utility cut command cuts out columns, fields, or characters displayed from standard input or from a file.
Use the fields field-list keyword and argument if the fields vary in length from line to line. (The lines must be separated by a delimiter character.) By default, the field delimiter character is the Tab key. Use the delimiter delimiter-character keyword and argument to specify a different delimiter.
Use the list character-list keyword and argument only if the fields are of a fixed length. Replace the character-list argument with the character positions to be extracted.
For the character-list argument, use a comma (,) to indicate more than one character, or use a dash (-) to indicate a range. For example, utility list 1,2,5 outputs the first, second, and fifth characters, utility list 1-64 outputs the first 64 characters of each line, utility list 5- outputs the fifth character to the end of the line.
You can also use the cut utility as a filter. If no files are specified, the keyboard input (standard input) is used.
Note |
Keywords are entered using the displayed syntax, or with UNIX-equivalent syntax. The UNIX-equivalent syntax is displayed in parentheses () in the syntax description. For example, the fields keyword can also be entered using the UNIX-equivalent (-f). To display the UNIX-equivalent syntax online, enter the usage keyword.
|
Examples
In the following example, the utility cut command is entered with the list character-list keyword and argument to display the first 10 characters in each line. The output is from the results of the show version command, which is entered with the pipe (|) character:
RP/0/0/CPU0:router# show version | utility cut list 1-10
Thu Feb 19 15:05:18.772 PST DST
Cisco IOS
Copyright
ROM: Syste
Copyright
PE21_C1240
System ima
cisco 1240
7457 proce
2 Cisco 12
2 Cisco 12
1 Cisco 12
3 Manageme
8 PLIM_QOS
6 T3
6 SONET/SD
6 Packet o
2 GigabitE
28 T1
--More--
In the following example, the utility cut command is used to extract fields from a file:
RP/0/0/CPU0:router# utility cut fields 1,5 delimiter : file disk0:/usr/passwd
root:Super-User
daemon:
bin:
sys:
adm:Admin
lp:Line Printer Admin
uucp:uucp Admin
nuucp:uucp Admin
listen:Network Admin
nobody:Nobody
In the following example, the utility cut command is used with the delimiter keyword to specify an alternative field delimiter:
RP/0/0/CPU0:router# utility cut fields 1,4,5 delimiter : file disk0:/usr/passwd
root:1:Super-User
daemon:1:
bin:2:
sys:3:
adm:4:Admin
lp:8:Line Printer Admin
uucp:5:uucp Admin
nuucp:9:uucp Admin
listen:4:Network Admin
In the following example, a range of fields is specified:
RP/0/0/CPU0:router# utility cut fields 1-4 delimiter : file disk0:/usr/passwd
root:x:0:1
daemon:x:1:1
bin:x:2:2
sys:x:3:3
adm:x:4:4
lp:x:71:8
uucp:x:5:5
nuucp:x:9:9
listen:x:37:4
In the following example, the list character-list keyword and argument are used to specify the character positions to be extracted:
RP/0/0/CPU0:router# utility cut list 1-30 file disk0:/usr/passwd
root:x:0:1:Super-User:/:/sbin/
daemon:x:1:1::/:
bin:x:2:2::/usr/bin:
sys:x:3:3::/:
adm:x:4:4:Admin:/var/adm:
lp:x:71:8:Line Printer Admin:/
uucp:x:5:5:uucp Admin:/usr/lib
nuucp:x:9:9:uucp Admin:/var/sp
listen:x:37:4:Network Admin:/u
nobody:x:60001:60001:Nobody:/:
noaccess:x:60002:60002:No Acce
nobody4:x:65534:65534:SunOS 4.
==========================================================================
In the following example, the UNIX equivalent options are used directly. First, the utility cut command is entered with the usage keyword to display the possible options. Next, the utility cut command is entered with the options to extract the desired data.
RP/0/0/CPU0:router# utility cut usage
cut -c list [file], cut -f list [-d delim] [-s] [file]
RP/0/0/CPU0:router# utility cut -f 1,4 -d : disk0:/usr/passwd
root:1
daemon:1
bin:2
sys:3
adm:4
lp:8