In a ssh server I can connect using sftp. In this server I have a list of mkv files witch is listed in m3u8 playlist. I want to download the mkvs but I want the download according to the order in the m3u8 playlist.

If I could use sh in sftp I would be able to do someting like:

while read line ; do
    if [[ $path != "#"* ]] ; do
        get $path
done < playlist.m3u8

(The if test if the line is a comment before download it)

Finaly I like to do someting like the -i wget’s option:

-i file


Read URLs from a local or external file.

So, how can I download files with sftp in the order of an m3u playlist?

1 Answer 1


Use -b: sftp -b or sftp -b - to read standard input. The batch file (or standard input) should contain sftp commands, such as, for example, get. See the manual page for details.

while read line; do
    if [[ $line != "#"* ]] ; do
        echo '-get' "$line"
done < "$playlist_file" | sftp -b - "$remote_user"@"$remote_host"

(Warning! Not tested.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .