Combine multiple cut commands into variable assignations into one cut command
yes, if you're ok with arrays:
var= ( $(echo $LINE | cut -d, --output-delimiter=' ' -f4-6) )
Note that that make var
0-indexed.
Though it might just be quicker and easier to turn the CSV $LINE
into something that bash parenthesis understand, and then just do var = ( $LINE )
.
EDIT: The above will cause issues if you have spaces in your $LINE... if so, you need to be a bit more careful, and AWK might be a better choice to add quotes:
var= ( $( echo $LINE | awk IFS=, '{print "\"$4\" \"$5\" \"$6\""}' ) )