In this tutorial, I am using cut command to remove sections from each line of files. Now, let’s go cut command in Linux for example.
What does cut command mean?
cut – remove sections from each line of files
Syntax
cut OPTION... [FILE]...
In the man page, the describe it
- cut – remove sections from each line of files.
- man cut – More details information about cut command.

cut command in Linux with example
I have created a file cut_command.txt as below
[vagrant@DevopsRoles ~]$ cat cut_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Hello world. xxx.
For delimiter separated fields. The default delimiter is the tab character.
[vagrant@DevopsRoles ~]$ cut -d "," -f 1 cut_command.txt HuuPV Devops Roles. Hello world. xxx
Get a list of all users in Linux
[vagrant@DevopsRoles ~]$ cat /etc/passwd | cut -d ':' -f1 root bin daemon adm lp sync shutdown halt mail uucp operator games gopher ftp nobody vcsa rpc rpcuser nfsnobody sshd exim centos huupv gluster grafana influxdb mysql acc1 netdata telegraf nginx dbus haldaemon
cut and sort sort
[vagrant@DevopsRoles ~]$ cat /etc/passwd | grep home | cut -d: -f1,6 | sort acc1:/home/acc1 huupv:/home/huupv
You can also display the table with column -t
[vagrant@DevopsRoles ~]$ cat /etc/passwd | grep home | cut -d: -f1,6 | sort | tr ":" " " | column -t acc1 /home/acc1 huupv /home/huupv
Conclusion
cut command is a simple command in Linux. It is used to remove sections from each line of files. Thank you for reading the DevopsRoles page!