Sitemap
Bugs That Bite

Helping make the world a better place, one error message at a time.

Member-only story

The cut command

3 min readApr 8, 2024

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Check out my series on Automating Cybersecurity Metrics | Code.

🔒 Related Stories: Bugs | AWS Security | Secure Code

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While trying to parse out errors and bits of logs or information in bash scripts I often find myself using cut. I thought I’d write a quick summary of how that command works here.

The cut command allows you to obtain a piece of a string based on a delimiter. Here’s the gist of it.

A delimiter can be any character such as a comma. It is the character that separates the parts of the string you want to get into a variable of view on the screen.

Let’s say you have a value like this:

apples,organges,bananas

The delimiter is the comma.

Let’s say you want to get the “apples” out of that string.

Set the variable to the value:

fruits="apples,oranges,bananas"

Echo the value to screen:

echo $fruits

Add a pipe character after the echo command which allows us to send the output of that command…

--

--

Teri Radichel
Teri Radichel

Written by Teri Radichel⁠

CEO 2nd Sight Lab | Pentesting | Research | AWS Security Hero | Masters of Infosec & Masters Software Engineering | GSE | IANS | SANS Difference Makers Award

Bugs That Bite
Bugs That Bite

Published in Bugs That Bite

Helping make the world a better place, one error message at a time.