|
#1
| ||||
| ||||
| Line feeds turn into space with backticks ! How to fix ? I have a long plain text file whose every line is a complete URL like http://server.com/file_xx.mp3 no spaces or quotes. Each line ends with (what appears with both pico and cat) a newline. My problem is that I need to use curl (or any other utility you can suggest) to download the files listed in fixed.txt. When I issue cat fixed.txt the file prints just fine with one URL per line. BUT if I issue echo `cat fixed.txt` the newlines get transformed into spaces. This is problematic because I'm downlading using curl -O `cat fixed.txt` so the first file downloads just fine but the subsequent files are outputted to STDOUT (i.e., binary data printed to the terminal and not to a file). Should I be using a script to read each subsequent line from fixed.txt to call a new instance of curl, or something ? I'm surprised simply backticking doesn't work !
__________________ michaelsanford.com Blog Twitter Tumblr LinkedIn iMac Aluminum 24" | MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2120 GB RAID 1, 2500 GB RAID 0 |
|
#2
| ||||
| ||||
| 1) Create a script, name it fx. curlGet -------------------------- #!/bin/bash while read line do `curl -O $line` done -------------------- 2) make it executable chmod +x curlGet 3) cat fixed.txt | ./curlGet 4) There is no 4 :-)
__________________ G4 500 MP 1024 MB RAM LaCie Electron 22" Display OS X 10.3.9 iMacDV MacMini iSight iPod + iPod Mini Sony PC100E FireWire Cam Static IP via a FreeBSD server/gateway a lot of other Mac's running Macos 7.5 to 9.1 and NetBSD. A Few Wintel's on the side (I only use them when I get paid by the hour) |
|
#3
| ||||
| ||||
| I had been working on a Perl script for a while, with many problems (not least of which being that ctrl-c-ing the script only broke the instance of curl that was running, and it just passed onto the next one). I changed it a bit to tell me which file it was downloading, but this is perfect and embarassingly simple, thanks! ![]() #!/bin/bash while read line do echo $line `curl -O $line` done and called it as ./get.bash < fixed.txt
__________________ michaelsanford.com Blog Twitter Tumblr LinkedIn iMac Aluminum 24" | MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2120 GB RAID 1, 2500 GB RAID 0 |
|
#4
| ||||
| ||||
| I love Curling, my girlfriend's a Linguist, so helping you out comes naturally :-)
__________________ G4 500 MP 1024 MB RAM LaCie Electron 22" Display OS X 10.3.9 iMacDV MacMini iSight iPod + iPod Mini Sony PC100E FireWire Cam Static IP via a FreeBSD server/gateway a lot of other Mac's running Macos 7.5 to 9.1 and NetBSD. A Few Wintel's on the side (I only use them when I get paid by the hour) |
|
#5
| ||||
| ||||
| Quote:
__________________ What is the robbing of a bank compared to the founding of a bank? -- Bertold Brecht |
|
#6
| ||||
| ||||
| :lol:
__________________ michaelsanford.com Blog Twitter Tumblr LinkedIn iMac Aluminum 24" | MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2120 GB RAID 1, 2500 GB RAID 0 |
![]() |
| Thread Tools | |
|
|