Bash read values and assign to variables

Bash read values and assign to variables

Read into array

read -r -a array <<< $line
echo ${array[3]}

Read into individual variables

read var0 var1 var2 var3 <<< $line
echo $var3

Read and format

awk '{print $2 "-" $3}' <<< $line

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


The reCAPTCHA verification period has expired. Please reload the page.