Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

How to split a string in bash

string="you got a friend in me"
IFS=' ' read -ra split <<< "$string"
echo "${split[*]}"
# Output: you got a friend in me
echo "${split[3]}"
# Output: friend
Comment

bash split string into variables

# separator is space
VAR="inforge srl bergamo"
read -r ONE TWO THREE <<< "${VAR}"
echo ${ONE}
echo ${TWO}
echo ${THREE}

# separator is comma
VAR="inforge,srl,bergamo"
IFS="," read -r ONE TWO THREE <<< "${VAR}"
echo "${ONE} ${TWO} ${THREE}"
Comment

split bash string

IN="bla@some.com;john@home.com"
arrIN=(${IN//;/ })
Comment

PREVIOUS NEXT
Code Example
Shell :: delete a file in linux 
Shell :: git take ours 
Shell :: install git lfs 
Shell :: remove gitignore files 
Shell :: linux source command vs dot 
Shell :: anbox install google play store 
Shell :: cordova android generate keystore 
Shell :: grep exact match 
Shell :: apache2 connection refused ubuntu 
Shell :: composer install one line 
Shell :: octave ubuntu 20.04 
Shell :: how to install cmake ninja 
Shell :: git switch 
Shell :: how to install android studio in ubuntu 
Shell :: shell curl extract bearer token from response 
Shell :: linux terminal show processes 
Shell :: permissão wordpress 
Shell :: rename remote branch in git 
Shell :: pushing existing project to github 
Shell :: linux command line search file by size 
Shell :: how to update your local repository 
Shell :: install automapper asp.net core mvc 
Shell :: github fork my own repo 
Shell :: configure github account ubuntu 
Shell :: echo in red color linux 
Shell :: kde vs gnome vs xfce 
Shell :: There is 1 zombie process 
Shell :: vieuw the MOTD linux 
Shell :: bash add comma to end of line 
Shell :: open current folder in terminal linux 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =