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

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.