본문 바로가기
반응형
Programming/Linux

[Shell] wget 명령어로 FTP 파일 or 폴더 다운로드

by JAMINS 2021. 10. 15.

외부 FTP에 있는 파일들을 Linux 서버로 다운로드 받아야하는 상황이다. 구현 방법에는 여러가지가 있지만 wget 명령어를 통해 특정 파일 또는 디렉토리에 있는 파일들을 한 번에 받는 방법이 있다.

특정 파일 다운로드

wget --user={username} --password={password} ftp://{host}/{directory_path}/{file_path} -O {download_path}

# Example (FTP경로 /picture/20211015/01.jpg 파일 다운로드하는 경우)
wget --user=user1 --password=test1234 ftp://111.222.333.444/picture/20211015/01.jpg -O ~/download/01.jpg

특정 폴더 내 전체 다운로드

특정 폴더 내에 있는 모든 파일을 다운로드하는 방법은 mirror 옵션을 사용하면 됨. (Root 가능)

wget -m --user={username} --password={password} ftp://{host}/{directory_path} -O {download_directory_path}

# Example (FTP경로 /picture/20211015 내 모든 파일을 다운로드)
wget -m --user=user1 --password=test1234 ftp://111.222.333.444/picture/20211015

# background 다운로드
wget -m --user=user1 --password=test1234 ftp://111.222.333.444/picture/20211015 -b

댓글