![파이프라인 내부에 변수를 할당하는 방법](https://linux55.com/image/83427/%ED%8C%8C%EC%9D%B4%ED%94%84%EB%9D%BC%EC%9D%B8%20%EB%82%B4%EB%B6%80%EC%97%90%20%EB%B3%80%EC%88%98%EB%A5%BC%20%ED%95%A0%EB%8B%B9%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
Bash에서 라이너를 만들고 있습니다.
임시 파일을 스크립팅하거나 작성하는 것이 선택 사항이었다면 물어볼 필요가 없었을 것입니다.
나중에 사용할 수 있도록 파이프 세트 중간에 변수를 할당해야 합니다.
cat list | awk '{print $1".modifications_to_name"' | (capture $NAME and pass $NAME down pipe) \
| checkStatus | grep pertinentinfo | cleanupFormatOfPertinentInfo | sendAlert $NAME
답변1
awk에 중괄호가 없다는 점을 무시하고 목록에 한 줄이 포함되어 있다고 가정하십시오.NAME=$( cat list | awk '{print $1".modifications_to_name"') && checkStatus | grep pertinentinfo | cleanupFormatOfPertinentInfo | sendAlert $NAME
여러 행이 포함된 목록을 반복하고 매번 다른 이름으로 평가하려면 다음을 수행하세요.
while read NAME; do checkStatus | grep pertinentinfo | cleanupFormatOfPertinentInfo | sendAlert $NAME ; done < <(cat list | awk '{print $1".modifications_to_name"')
이것은 것 같다XY그래도 문제가 있습니다.