log 파일중 분당 특정문자 count 수를 구하고 싶습니다.

kkam8080의 이미지

grep 'error' access.20211014.log | grep -o "[0-9]\{4,4\}\/[0-9]\{2,2\}\/[0-9]\{2,2\} 0[7-9]\{1,1\}" | sort | uniq -c

17 2021/10/14 07
616 2021/10/14 08
46 2021/10/14 09

기존꺼는 시간대별로 07시~09시까지 카운트한건데, 해당 log 에서 분당으로 count 할려면 어떻게 해야될까요??

조언 부탁 드립니다.

ymir의 이미지

$ cat /var/log/apache2/access.log.1 | grep -Po "\[.*\]" | tr -d '[]' | \
> while IFS='/:' read day mon yr hr min etc; do echo $yr/$mon/$day $hr:$min; done | uniq -c
      3 2021/Apr/22 11:07
      3 2021/Apr/22 13:27
      2 2021/Apr/22 13:36
      2 2021/Apr/22 13:38
      1 2021/Apr/22 13:39
     73 2021/Apr/22 13:46

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

kkam8080의 이미지

감사합니다.저는 왜 안될까요... 수행해보니 에러가 나네요 ㅠㅠ

[root@localhost Logs]#cat KMServer.4409.20211014.KMO.log | grep -Po "\[.*\]" | tr -d '[]' | \
> while IFS='/:' read day mon yr hr min etc; do echo $yr/$mon/$day $hr:$min; done | uniq -c
-bash: syntax error near unexpected token `do'

해당로그에서 특정문자 "KMO" 찍힌거를 1분단위로 카운트 해야되는데 고수님들 도와주세요 ㅠㅠ

ymir의 이미지

명령 두 줄을 copy & paste 해서 한 번에 붙여 넣으셨나요?
첫 번째 줄의 \ 는 쉘에 명령 입력이 다 끝나지 않고 계속 이어지고 있다는 걸 알려주는 역할을 합니다.
이 경우 두 번째 줄의 프롬프트가 > 로 바뀌죠.

만약 그렇게 > 까지 붙여 넣으셨다면, > 뒤의 while 은 파일명으로 인식되기 때문에..
올리신 글처럼 뜬금없이 do 가 튀어나왔다는 에러가 찍힐 겁니다.

근데 이 경우에는 > while 앞에 프롬프트 > 가 하나 더 있었을 텐데.. 그건 지우신건가요?
화면에 나타난 걸 정확하게 설명하지 않으시면, 말이 안 되는 상황이라서 답변 달기가 어렵습니다.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.