thank you thank you - 16 days ago 10
Bash Question

Having <<< error

I am having this error using "<<<" can someone help me with this?

resulttrim = 09091929394959697
echo "$resulttrim" | sed 's/.\{2\}/& /g'

read -r -a Words <<< "$resulttrim"


The error msg is

line 31: syntax error near unexpected token `<<<'

Answer

This might help:

#!/bin/bash

# no whitespaces before and after =
resulttrim="09091929394959697"

# save stdout to variable $resulttrim
resulttrim=$(echo "$resulttrim" | sed 's/.\{2\}/& /g')

read -r -a Words <<< "$resulttrim"
declare -p Words

Output:

declare -a Words='([0]="09" [1]="09" [2]="19" [3]="29" [4]="39" [5]="49" [6]="59" [7]="69" [8]="7")'
Comments