wget과 같은 유틸리티를 다운로드하기 위한 URL을 한 줄로 결합합니다.

wget과 같은 유틸리티를 다운로드하기 위한 URL을 한 줄로 결합합니다.

다음 wget코드를 고려해보세요:

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh

위와 동일한 기본 URL을 가진 여러 터미널을 2개 이상이 아닌 한 줄로 통합하는 우아한 방법이 있습니까?

의사코드:

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh

답변1

여러 URL이 한 번에 허용 되므로 wget중괄호 확장을 사용하여 이를 수행할 수 있습니다 bash.

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/{papj.sh,nixta.sh}

(심지어

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/{papj,nixta}.sh

그러나 물론 이것은 매우 적합한 이름에서만 작동합니다.

답변2

저는 awk 명령과 for 루프를 사용하여 이 작업을 수행했습니다. 궁금한 점이나 혼란스러운 점이 있으면 알려주세요.

파일에 다음 내용을 넣어 example.txt 파일을 생성했습니다.

고양이 예시.txt

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/

변수 i에 papj.sh nixta.sh를 할당했습니다.

아래 스크립트를 사용하여 요구 사항에 따라 실행하십시오.

for i in papj.sh nixta.sh; do awk -v i="$i" '{print $0i}' example.txt; done

산출

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh

관련 정보