regex - split string in one liner in bash or ksh or perl -


var="valuea valueb" 

i want split above string shown below , want read value in 1 liner on bash shell.

following script not working .

echo $var |awk '{print $1  $2}' |while read var; echo  var1=$1 , var2=$2;done   echo $var |awk '{ var1=$1 ; var2=$2}' |while read var1 var2; echo  var1=$var1 , var2=$var2;done  

in ksh93, work of shelf:

echo "$var" |     read var1 var2 &&         echo $var1 --- $var2 

effectively same https://stackoverflow.com/a/32855720/667820, values of $var1 , $var2 preserved.

for bash, need bash 4.x , options need (un)set.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -