Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

When using a Bash script to retrieve files that have spaces in their names from sftp, you can escape the spaces in the file names by adding a backslash () before each space.

For example, if the file you want to retrieve is named "file with spaces.txt", you would use the following command:

sftp username@server:/path/to/file\ with\ spaces.txt /local/path/

Alternatively, you can enclose the entire file name in quotes:

sftp username@server:"/path/to/file with spaces.txt" /local/path/

Both of these methods will retrieve the file with spaces in the name from sftp and save it to the specified local path.