Member-only story
The cut command
A useful command in bash scripts you can use to parse data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ 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,bananasThe 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 $fruitsAdd a pipe character after the echo command which allows us to send the output of that command…









