Ask Your Question
1

How to retrieve files that have spaces in their names from sftp using a Bash script?

asked 2023-05-12 13:57:25 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-12 14:24:02 +0000

pufferfish gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-12 13:57:25 +0000

Seen: 12 times

Last updated: May 12 '23