I'm trying to write a bash script that makes it easier to use rtmpdump for downloading Flash lecture videos. I've gotten pretty much everything else to work except for using cURL to grab the necessary mp4 URL from the XML page.When I run the following command in my terminal, I get what I want:curl -s http://amps-web.amps.ms.mit.edu/courses/6/6.046/2017spring/L01/MIT-6.046-lec-mit-0000-2017feb09-1103-L01/settings-flash.xml | grep rtmp:yields: rtmp://flashsvr1.amps.ms.mit.edu/6.046/mp4:2017spring/MIT-6.046-lec-mit-0000-2017feb09-1103-L01.mp4</url> (I'm aware of the trailing header, it's taken care of in my bash script)However, when I try to run the same command in my bash script and save the output to a variable, I get nothing. Running just xml=$(curl -s $url) and echoing that out results in a bunch of (but not all) headers, nothing else:<camera id=2 cameraX=960 cameraY=0 thumbnailX=960 thumbnailY=0 name=CAM2 selectedName=LIVE 2 <camera id=3 cameraX=0 cameraY=540 thumbnailX=0 thumbnailY=540 name=CAM3 selectedName=LIVE 3 <camera id=4 cameraX=960 cameraY=540 thumbnailX=960 thumbnailY=540 name=CAM4 selectedName=LI <fullscreenOutButtonImageOver>fallback/assets/btn_fullscreenOff_selected.png</fullscreenOutButtonImageOve <fullscreenOutButtonImageDown>fallback/assets/btn_fullscreenOff_selected.png</fullscreenOutButtonImageDow <communityRealOutButtonImageNormal>fallback/assets/buttons/community_selected_up.png</communityRealOutBut <communityRealOutButtonImageOver>fallback/assets/buttons/community_over.png</communityRealOutButtonImageO <communityRealOutButtonImageDown>fallback/assets/buttons/community_down.png</communityRealOutButtonImageD <thumbspositionTopButtonImageNormal>fallback/assets/btn_thumbnailPositionTop.png</thumbspositionTopButton <thumbspositionBottomButtonImageNormal>fallback/assets/btn_thumbnailPositionBottom.png</thumbspositionBot </settings>ge>fallback/assets/affiche.png</landingImage>>ng</thumbnailActive>Progress>geDown>Down>Does anyone know what might be happening with this? It's quite frustrating. Thanks!
cURL response not showing body of XML
shell script;curl;xml
Your data has carriage-returns in it. Filter them out:curl ... | tr -d '\r'Also, quote your variable when you echo it:$ echo $xmlOr even better:$ printf '%s\n' $xmlQuoting prevents word-splitting. Word-splitting happen on all unquoted variables on the command line and involves splitting them line into words based on the value of $IFS. $IFS is by default a tab-character and a space-character and a new-line character. See Word Splitting or Field Splitting in the manual for your shell.