Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VALUES="
- val1 ;val2 ;val3
- another1;another2;another3
- "
- VALUES="
- val1 ;val2 ;val3
- another1;another2;another3
- "
- echo "$VALUES" | while IFS=' ;' read v1 v2 v3; do
- [[ -z $v1 && -z $v2 && -z $v3 ]] && continue
- echo "v1=$v1 v2=$v2 v3=$v3"
- done
- v1=val1 v2=val2 v3=val3
- v1=another1 v2=another2 v3=another3
- typeset -a values
- typeset -i i=0
- echo "$VALUES" | while IFS=' ;' read v1 v2 v3; do
- [[ -z $v1 && -z $v2 && -z $v3 ]] && continue
- values[i]=$v1
- values[i+1]=$v2
- values[i+2]=$v3
- ((i+=3))
- done
- for i in "${!values[@]}"; do printf "%dt%sn" $i "${values[i]}"; done
- 0 val1
- 1 val2
- 2 val3
- 3 another1
- 4 another2
- 5 another3
- echo "$VALUES"|awk -F' *; *' 'NF>1{print $1, $2, $3}'
- val1 val2 val3
- another1 another2 another3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement