Skip to main content

Linux command: cut

Illustration: Scissors | src: https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjSzIjQlbjhAhWt-GEKHZMyCEMQjRx6BAgBEAU&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFile%3AScissors_icon_black.svg

cut - remove sections from each line of files

$ which cut
/usr/bin/cut
$ cut --version
cut (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David M. Ihnat, David MacKenzie, and Jim Meyering.

Examples of cut

List all VMs in Qubes OS, then use cut to get the first column

Qubes OS: list all VMs

$ qvm-ls | cut -d " " f 1 # Number 1 NOT letter L
$ qvm-ls | cut -d" " f1  # or NO space in between options and value
Use cut to get the first column

Extract username and id from /etc/passwd file

Delimiter is ":", username is in column 1 and id is in column 3.

$ cut -d: -f1,3 /etc/passwd
Extract username and id from /etc/passwd file
'cut' selects columns, 'head' and 'tail' select rows

Popular posts from this blog

VMware Workstation: Backup inventory and preferences

Backup these two files in your profile.

Microsoft Azure Web App Service

Three steps to create a FREE web app on Microsoft Azure using Azure CLI .