Linux cut command

Linux cut command is used to pick the given expression and display the output.

Examples:

[root@localhost k2admin]# cut -d: -f1 /etc/passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
uucp
operator
games
gopher
ftp
nobody
dbus
usbmuxd
vcsa
rtkit
avahi-autoipd
abrt
haldaemon
gdm
saslauth
postfix
ntp
apache
pulse
sshd
tcpdump
administrator
enterprisedb
k2admin

To delimit spaces and print field

[root@localhost k2admin]# cut -d ” ” -f1 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System
usbmuxd:x:113:113:usbmuxd
vcsa:x:69:69:virtual
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi
abrt:x:173:173::/etc/abrt:/sbin/nologin
haldaemon:x:68:68:HAL
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
saslauth:x:498:76:”Saslauthd
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
pulse:x:497:496:PulseAudio
sshd:x:74:74:Privilege-separated
tcpdump:x:72:72::/:/sbin/nologin
administrator:x:500:500:administrator:/home/administrator:/bin/bash
enterprisedb:x:501:501:Postgres
k2admin:x:502:502::/home/k2admin:/bin/bash

Powered by k2schools
Skip to toolbar