![파이프라인 gnuplot 출력](https://linux55.com/image/79691/%ED%8C%8C%EC%9D%B4%ED%94%84%EB%9D%BC%EC%9D%B8%20gnuplot%20%EC%B6%9C%EB%A0%A5.png)
에서 영감을 받다이 문제출력을 gnuplot으로 파이프한 다음 플로팅해 보았습니다.
내 파이프라인은 다음과 같습니다.
cat file.txt |
grep CU |
perl -e 'while(<>){print +(split)[3], "\n"}' |
gnuplot file.gp
여기서 file.gp에는 다음 내용이 포함되어 있습니다.
set terminal dumb
plot '<perl' using 1
파이프의 출력은 다음과 같습니다.
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-7.78333787544e+01
-7.78333787544e+01
이제 다음 오류가 발생합니다.
plot '<perl' using 1
^
"file.gp", line 3: warning: Skipping data file with no valid points
plot '<perl' using 1
^
"file.gp", line 3: x range is invalid
출력을 파일로 파이프한 다음 파일 이름을 포함하도록 gnuplot file.gp
수정을 수행하면 제대로 작동했습니다.file.gp
내가 여기서 뭘 잘못하고 있는 걸까?
답변1
이 질문을 올리려고 할 때 인터넷 연결이 끊어져서 스스로 몇 가지를 더 시도하고 마침내 방법을 알아 내야했습니다. 하지만 이제 문제에 대해 글을 썼으니 새로 발견한 지식을 공유하는 것이 좋겠다고 생각했습니다. 또한 더 많은 통찰력을 제공하는 다른 답변을 권장합니다.
내 해결책은 file.gp
다음과 같이 변경하는 것이 었습니다.
set terminal dumb
plot '<cat' using 1
그런 다음 파이프 체인을 이렇게 조정하십시오.
cat file.txt |
grep CU | #I put an identifier in the file
perl -ne 'print +(split)[3], "\n"' | #strip the identifier
cat | #this makes gnuplot accept the output from the pipe
gnuplot file.gp