리눅스 명령어 관련 질문 있어요 ^_^

gdhome의 이미지


이 포럼에 올리는게 맞는지 잘 모르겠네요 :) 처음이라..

다름이 아니라 로그를 빼려고

ssh xxx.xxx.xxx.xxx "tail -f /usr/local/apache-tomcat-6.0.20/logs/catalina.out" | grep "STRING" >> a.out

같이 하였는데요 쌓이지가 않아서요

ssh xxx.xxx.xxx.xxx "tail -f /usr/local/apache-tomcat-6.0.20/logs/catalina.out" >> a.out

으로 하면 잘 빠지는데 말이죵;

리눅스를 많이 안해봐서 아직 파이프 개념이 없어서 그런지..

왜 안돼는지 원리좀 가르쳐 주실수 있나요 ^_^

doodoo의 이미지

tail 에 -f 옵션을 쓴것으로 보아..연속적으로 뽑아 보기 위함인가요?

아니면 -f 빼고 해 보시죠?

실제로 -f 를 쓰면 ssh 명령이 종료가 되지 않지요. 계속입력을 기다리는 형태가
되니까요......

artop0420의 이미지

grep 문에서 따옴표를 제거 해보면요?
STRING이라는 문자열만 빼서 a.out에 추가하시려고 하는것 같은데 만약에 그런거라면
STRING 앞뒤에 있는 따옴표를 제거해보심도 좋을듯...

생각해보니 따옴표랑은 상관이 없겠군요.. 음 ㅡㅡ;;; 지송

--- 나는요? ---

리눅스와 솔라리스 그리고 윈도우의 껍데기만 맛보고 있습니다.

--- 나는요? ---

리눅스와 솔라리스 그리고 윈도우의 껍데기만 맛보고 있습니다.

gdhome의 이미지

음...ssh xxx.xxx.xxx.xxx "tail -f /usr/local/apache-tomcat-6.0.20/logs/catalina.out" | grep "STRING"

자체가 표준 출력을 계속하는데 그걸 >> 로 빼내지 못하는 이유가 뭘까요 ㅠ

실은 저 로그에서 특정 형식 으로 출력을 포맷해서 뽑으려는건데요

doodoo의 이미지

해보니 진짜 안되는 군요...

구굴신께...쫌 구걸해 봤습니다.

http://www.linuxquestions.org/questions/linux-newbie-8/trying-to-understand-pipes-cant-pipe-output-from-tail-f-to-grep-then-grep-again-646932/

arungoodboy 아이디의 쓴 글을 인용하면...

There's nothing a little googling can't solve! The root cause is grep's behaviour, not the pipes'. Apparently grep buffers the results so you won't (or may not) get the output instantaneously. The argument --line-buffered to the first grep solves your problem.

라는 군요... 영어는 안돼지만 grep 이 즉시로 증분되어 들어오는 걸 출력으로 안 내어 준다?
모..대충 그런것 같네요...

결론..
ssh xxx.xxx.xxx.xxx "tail -f /usr/local/apache-tomcat-6.0.20/logs/catalina.out" | grep "STRING" >> a.out 는

ssh xxx.xxx.xxx.xxx "tail -f /usr/local/apache-tomcat-6.0.20/logs/catalina.out" | grep --line-buffered "STRING" >> a.out 로 하라...

테스트 해보니 잘 되네요..ㅎㅎ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.