![프로그램 출력이 grep이 아닌 이유는 무엇입니까? [복사]](https://linux55.com/image/122355/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8%20%EC%B6%9C%EB%A0%A5%EC%9D%B4%20grep%EC%9D%B4%20%EC%95%84%EB%8B%8C%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
내가 실행하면 sudo wpa_supplicant -Dwext -iwlan3 -cwifi.conf 2>&1
다음을 얻습니다.
Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell514' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
그러나 내가 실행할 때 :
sudo wpa_supplicant -Dwext -iwlan3 -cwifi.conf 2>&1 | grep --line-buffered wlan3
나는 단지 다음을 얻습니다:
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
올바르게 리디렉션되지 않습니까 stderr
?
답변1
파이프라인 소비자 grep은 라인 버퍼링됩니다. 그러나 이는 파이프 제조업체에는 영향을 미치지 않습니다. 파이프 grep의 해당 측면을 조정하면 원하는 출력이 생성됩니다.