I thought I was familiar with sftp commands in unix and upto my knowledge the command to used to download a compressed file from the server is

sftp get filename.tar.gz

But when I tried this command the file gets emptied, I mean the file size is going 0 and I don't know why it happens. Is there any other command specifically for .tar.gz type of files. What is the procedure to get this compressed files. I'm using mac terminal.

  • 2
    Don't you have to include the server address? What is the exact command you typed? – Faheem Mitha Nov 11 '14 at 6:58
  • @FaheemMitha I've entered into server using sftp command. sftp user[at]server and in the sftp terminal I used > get filename.tar.gz – GIRI Nov 11 '14 at 16:13

get is a legal sftp command, but can't be used that way.

The correct syntax to download filename.tar.gz to your Mac is:

sftp user@host:/path/to/filename.tar.gz /some/local/folder

(Replace user with the user you use to connect to the remote server, replace host with the remote server name.)

There's nothing special to tar.gz files in the above command, it is generic to any extension.

To use get you have to enter interactive mode first:

  1. Make a connection to the remote server:

    sftp user@host

    Wait until >, the sftp prompt, appears in a newline - you can now type your commands.

  2. Change the remote path to /path/to:

    cd /path/to/
  3. Change the local path to /some/local/folder:

    lcd /some/local/folder
  4. Use get to download the file:

    get filename.tar.gz
  • No, its not working I tried your suggestions. tried changing the local paths but no effect. – GIRI Nov 11 '14 at 16:09
  • Could you post the output of the sftp command? – jaume Nov 11 '14 at 18:33
  • There is no such output kind of thing, as type sftp > get filename.tar.gz the file doesn't gets downloaded and the memory turns to be 0. – GIRI Nov 13 '14 at 4:00
  • Neither sftp > get filename.tar.gz nor, as posted in your question, sftp get filename.tar.gz will work. The correct syntax is sftp user@host:/path/to/filename.tar.gz /some/local/folder, as explained in my answer. What happens when you type the command (replace user, host, /path/to and /some/local/folder with values that are correct in your environment) in Terminal and then press Enter? Is there any output? If so, please add it to our question. – jaume Nov 14 '14 at 10:10
  • There is NO output. it just goes to next line. – GIRI Nov 14 '14 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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