Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bash script that cd to the right directory then uses the mput command to ftp all the files in the directory to a remote server, as below:

for from_dir in $DATE_LIST 
do
    cd ${FILE_LANDING_DIR}/deltas/${from_dir}
    ftp_files
done

ftp_files () {
    ftp -inv $HOST <<-EOF > $LOG_DIR/tempftplog
    user $USER $PASS 
    cd ${ID_LANDING_DIR}
    mput *
    bye 
    EOF
} 

I tried altering the ftp_files function to ftp only the .gz files in that directory by changing the line from mput * to mput *.gz but that did not work.

Can someone tell me how I can do this once in the ftp command?

share|improve this question
up vote 0 down vote accepted

Does mput *.gz not work? If not, try the ftp glob command first.

http://man.cx/ftp

share|improve this answer

What about performing a directory search and piping it to the mput?

ls *.gz | mput

I cannot test this right now because Im not at a linux box so it might need to be tweaked to get it to work 100% correctly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.