0
#FileList. list.txt Delivery list belowt
  $1          $2           $3
xxxx1.com_1 Hello_2 Hello_3 - Hello
xxxx2.com_1 Hello_2 Hello_3 - Hello
get_list() {      
    while read -r now_list_url now_list_keyword now_list_title; do

    echo "url:${now_list_url}"
    # result: xxxx1.com_1

    echo "keyword:${now_list_keyword}"
    # result: Hello_2

    echo "title:${now_list_title}" 
    # result: Hello_3 - Hello

    #I give the text_deliver method
    text_deliver ${now_list_url} ${now_list_keyword} ${now_list_title}
 
done < "${now_list}"
}
text_deliver() {

           url="$1"
           keywrod="$2"
           title="$3"

           echo "title:${url}"
           # result: xxxx1.com_1

           echo "title:${keywrod}"
           # result: Hello_2

           # I convey three variables to the text_deliver method, but there is a space in the 
           # medium value of the variable 3 and is intercepted. How should I solve
           echo "title:${title}"
           result:Hello_3
    
           # And what I want to pass is the complete variable value
           # I want the correct value:Hello_3 - Hello
           # result: Hello_3 - Hello
           echo "title:${title}"
           result:Hello_3 - Hello
}

#Run
get_list list.txt

I convey three variables to the text_deliver method, but there is a space in the medium value of the variable 3 and is intercepted. How should I solve echo "title:${title}" result:Hello_3

BashShell I should better deal with the problem of space in the transmission value, and I want to pass the value is complete How should I deal with it, thank you for everyone

tripleee
  • 175,061
  • 34
  • 275
  • 318
study
  • 1
  • 5

0 Answers0