[geeks] ksh for loop question
    David Passmore 
    dpassmor at sneakers.org
       
    Fri May 10 11:16:34 CDT 2002
    
    
  
On Fri, May 10, 2002 at 11:54:33AM -0400, Brian Hechinger wrote:
> ok, i have a list of files that unfortunately have spaces in them.  i'd like
> to get this list of files from a server using wget, so i was looking to just
> use a for loop to go and get them all, for example:
> 
> for files in `cat file_list.txt`; do
>   wget "http://www.server.com/$files"
> done
> 
> this of course fails misserably since for splits by whitespace.  how do i do
> something like this, but split by line not by whitespace?  and please don't
> say perl.
Here is a shell script that will do it...
----
#!/bin/sh
cat file_list.txt | perl -n -e 'system("wget http://www.server.com/$_");'
----
David
    
    
More information about the geeks
mailing list