Skip to content

How to split a string on a delimiter in bash

Advertisement

We can use an internal field separator (IFS) variable to parse an array. Let’s use an example script, where first we define a string with colon-separated. Then we will use IFS to separate values based on a delimiter.

Let’s execute this script and check for results.

./myscript.sh 
Output:
orange grapes banana apple

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top