Search code examples
bashshellecho

bash shell script is putting the last item first when I echo or try to create a command


I'm confused. Why is the last item being echoed first?

echo -e "\n\nPROCESS: cik : $cik companyName : $companyName form : $form date : $dateStr textURL : $textURL ID : $ID"

OUTPUT:

ID : 6f89f534-2c81-4338-89ac-f691c842b8f1LION FINANCIAL CORP form : 40-17F2 date : 2017-01-05 textURL : edgar/data/1000209/0001193125-17-002593.txt

It does this for one other attempt to create a curl command.

echo curl -XPUT "$ES_HOST/edgar/filing/$ID" -H 'Content-Type: application/json' -d'{"cik":"'$cik'","companyName":"'$companyName'","form":"'$form'","date":"'$date'","textURL":"'$textURL'","data":"'$data'"}'

which gets printed as

 -o /tmp/foo.txt.sec.gov/Archives/edgar/data/1000209/0001193125-17-002593.txt

WTH is going on?


Solution

  • My guess is that $textURL has a carriage return at the end of it, so the cursor is being moved back to the start of the line before the id is printed