[TAG] Unix

Neil Youngman ny at youngman.org.uk
Mon Oct 8 11:49:26 MSD 2007


On or around Monday 08 October 2007 08:16, Terry T reorganised a bunch of 
electrons to form the message:
> Hie
> I am new UNIX.I want to copy 30 files with different names using the
> following command.
>
> ftp -i -s:filename > logfilename.log
>
> The command works well.
>
> My problem is to type the same command 30 times for each file name.
> How do I transfer all the 30 files at the same time?

That looks like a different ftp client to the one I have. My man page does not 
show a -s option. There are as always a number of possible solutions. 

You can use an ftp client that allows you to specify multiple files on the 
command line, e.g. ncftpput

Alternatively you can use a loop. If you are using the BASH shell a loop to 
send all files with the .txt extension in the current directory would look 
like

  for file in  *.txt
  do
    ftp -i -s:$file
  done > logfilename.log 2>&1

If you want to see error messages on the screen, while still capturing them in 
the log, you can use tee, e.g.

  for file in  *.txt
  do
    ftp -i -s:$file
  done 2>&1 | tee logfilename.log

HTH

Neil Youngman





More information about the TAG mailing list