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

Ansible on Fedora Workstation 30

RedHat acquired Ansible in 2015 .

MSSQL: Fix error 'Consistency validation for SQL Server registry keys'

While installing Microsof SQL Server 2012, I ran into the following error. "The SQL Server registry keys from a prior installation cannot be modified. To continue, see SQL Server Setup documentation about how to fix registry keys." How to fix Replace the D:\x64\FixSqlRegistryKey_x86.exe file with the original file from the ENU\SQLFULL_ENU.iso file downloading from Microsoft Download Center. This ISO file is 4.2GB. So you can click FixSqlRegistryKey_x86.exe to download this file only. After replacing that file, press Re-run to check. All rules are passed.

Install Microsoft .NET Core SDK

.NET Core Software Development Kit (SDK) is a set of libraries and tools that allow developers to create .NET Core applications and libraries.