
다운로드하려는 URI 목록으로 구성된 구성 파일이 있습니다. 예를 들어,
http://xyz.abc.com/Dir1/Dir3/sds.exe
http://xyz.abc.com/Dir2/Dir4/jhjs.exe
http://xyz.abc.com/Dir1/itr.exe
구성 파일을 읽고 각 URL을 복사하면서 동시에 호스트에서와 동일한 디렉터리 구조를 만들고 싶습니다. 예를 들어 구성 파일의 첫 번째 줄에 대해 로컬 컴퓨터에 Dir1/Dir3 디렉터리 구조를 만든 다음(존재하지 않는 경우) sds.exe를 .../Dir1/Dir3/에 복사하려고 합니다.
'wget -i'를 사용하여 파일의 모든 URL을 다운로드할 수 있다는 것을 알았습니다. 그런데 이를 사용하여 해당 디렉토리 구조를 어떻게 만들 수 있습니까?
답변1
에서 man wget
:
-x, --force-디렉토리:
[...]
그렇지 않은 경우 디렉토리 계층 구조를 생성합니다. 예: wget -xhttp://fly.srk.fer.hr/robots.txt다운로드한 파일을 fly.srk.fer.hr/robots.txt에 저장합니다.
답변2
원하는 구조를 얻으려면 -x뿐만 아니라 -nH도 사용하는 것이 좋습니다.
이렇게 하면 호스트 이름이 제거되고 예상되는 디렉터리 구조가 생성됩니다.
예를 들어
wget -x -nH http://xyz.abc.com/Dir1/Dir3/sds.exe
- 'Dir1/Dir3/sds.exe' saved [1234]
매뉴얼 페이지에서:
-nH
--no-host-directories
Disable generation of host-prefixed directories. By default, invoking Wget with -r http://fly.srk.fer.hr/ will create a structure of directories beginning with fly.srk.fer.hr/. This option disables such behavior.
-x
--force-directories
...create a hierarchy of directories, even if one would not have been created otherwise...