MYSYSAD.COM

Select Fields or Columns Using the cut Command

· Shell & text

Selecting fields and columns is a common task for system administrators. The cut command is an ideal utility for accomplishing this task. Here are examples of its use (selecting disk slices and checking for passwords).

#df -k grep c0 grep d0s cut -b16-17
s0
s3
s4
s5
s7

#cut -d: -f1-3 /etc/shadow

# cut -d : -f 1-2,7 /etc/passwd
root:x:/sbin/sh
daemon:x:
bin:x:
sys:x:
adm:x:
lp:x:
uucp:x:
nuucp:x:/usr/lib/uucp/uucico
listen:x:
nobody:x:
noaccess:x:
nobody4:x:
t1:x:/bin/csh
restrict:x:/bin/rksh
t2:x:/bin/csh