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?


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.)

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.