编辑

编辑

grep我正在尝试对 Android 日志进行扩展。但是,我无法匹配它的锚点。

这是我的查询 -

grep -A 25 -E 'show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible$'

我想匹配

  • show(authenticated =或者
  • onAllPanelsCollapsed()或者
  • makeExpandedInvisible 在该行的末尾

然而,我总是得到的输出是

D/KeyguardBouncer(  855): show(authenticated = false) is called.
D/KeyguardBouncer(  855): show(authenticated = false) is called.
W/System.err(  855): java.lang.Throwable: stack dump
W/System.err(  855):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  855):    at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:91)
W/System.err(  855):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.showBouncer(StatusBarKeyguardViewManager.java:134)
W/System.err(  855):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:334)
W/System.err(  855):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:326)
W/System.err(  855):    at com.android.systemui.statusbar.phone.PhoneStatusBar.showBouncer(PhoneStatusBar.java:3888)
W/System.err(  855):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2564)
W/System.err(  855):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  855):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  855):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)

即使我使用的是extended grep,我也无法匹配,makeExpandedInvisible但其他模式工作正常。


编辑

匹配 -

 grep -A 25 -E 'show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible'

D/KeyguardBouncer(  850): show(authenticated = false) is called.
D/KeyguardBouncer(  850): show(authenticated = false) is called.
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:91)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.showBouncer(StatusBarKeyguardViewManager.java:134)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:334)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:326)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.showBouncer(PhoneStatusBar.java:3888)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.onTrackingStopped(PhoneStatusBar.java:3953)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView.onTrackingStopped(PhoneStatusBarView.java:164)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.onTrackingStopped(PanelView.java:373)
W/System.err(  850):    at com.android.systemui.statusbar.phone.NotificationPanelView.onTrackingStopped(NotificationPanelView.java:1492)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.onTouchEvent(PanelView.java:340)
W/System.err(  850):    at com.android.systemui.statusbar.phone.NotificationPanelView.onTouchEvent(NotificationPanelView.java:649)
W/System.err(  850):    at android.view.View.dispatchTouchEvent(View.java:8486)
W/System.err(  850):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2535)
W/System.err(  850):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2220)
W/System.err(  850):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)
W/System.err(  850):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)
W/System.err(  850):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2541)
W/System.err(  850):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2234)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarWindowView.dispatchTouchEvent(StatusBarWindowView.java:175)
W/System.err(  850):    at android.view.View.dispatchPointerEvent(View.java:8687)
W/System.err(  850):    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4485)
W/System.err(  850):    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4343)
W/System.err(  850):    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3884)
--
I/PhoneStatusBarView(  850): onAllPanelsCollapsed()
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView.onAllPanelsCollapsed(PhoneStatusBarView.java:116)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelBar.panelExpansionChanged(PanelBar.java:191)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView.panelExpansionChanged(PhoneStatusBarView.java:180)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.notifyBarPanelExpansionChanged(PanelView.java:898)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.setExpandedHeightInternal(PanelView.java:639)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView$10.onAnimationUpdate(PanelView.java:891)
W/System.err(  850):    at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1283)
W/System.err(  850):    at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207)
W/System.err(  850):    at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248)
W/System.err(  850):    at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659)
W/System.err(  850):    at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
--
I/PhoneStatusBar(  850): makeExpandedInvisible
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2528)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
I/PanelView(  850): setExpandedHeight(): height: 0.0
I/PanelView(  850): setExpandedHeightInternal(): height: 0.0
D/PanelBar(  850): panelExpansionChanged: start state=0 panel=null
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelBar.panelExpansionChanged(PanelBar.java:164)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView.panelExpansionChanged(PhoneStatusBarView.java:180)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.notifyBarPanelExpansionChanged(PanelView.java:898)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.setExpandedHeightInternal(PanelView.java:639)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.setExpandedHeight(PanelView.java:588)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.setExpandedFraction(PanelView.java:665)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelBar.collapseAllPanels(PanelBar.java:209)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2534)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
D/PanelBar(  850): panelExpansionChanged: end state=0 [ fullyClosed ]
D/PanelBar(  850): panelExpansionChanged: start state=0 panel=null
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelBar.panelExpansionChanged(PanelBar.java:164)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView.panelExpansionChanged(PhoneStatusBarView.java:180)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.notifyBarPanelExpansionChanged(PanelView.java:898)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelView.cancelPeek(PanelView.java:748)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PanelBar.collapseAllPanels(PanelBar.java:211)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2534)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
D/PanelBar(  850): panelExpansionChanged: end state=0 [ fullyClosed ]
D/StatusBarKeyguardViewManager(  850): dismiss(authenticated = false) is called. mScreenOn = true
D/KeyguardBouncer(  850): show(authenticated = false) is called.
D/KeyguardBouncer(  850): show(authenticated = false) is called.
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:91)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.showBouncer(StatusBarKeyguardViewManager.java:134)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:334)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:326)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.showBouncer(PhoneStatusBar.java:3888)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2564)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
D/KeyguardViewBase(  850): show()
D/KeyguardViewBase(  850): KeyguardViewBase.show()
W/System.err(  850): java.lang.Throwable: stack dump
W/System.err(  850):    at java.lang.Thread.dumpStack(Thread.java:490)
W/System.err(  850):    at com.android.keyguard.KeyguardViewBase.show(KeyguardViewBase.java:131)
W/System.err(  850):    at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:97)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.showBouncer(StatusBarKeyguardViewManager.java:134)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:334)
W/System.err(  850):    at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.dismiss(StatusBarKeyguardViewManager.java:326)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.showBouncer(PhoneStatusBar.java:3888)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBar.makeExpandedInvisible(PhoneStatusBar.java:2564)
W/System.err(  850):    at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:121)
W/System.err(  850):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795)
W/System.err(  850):    at android.view.Choreographer.doCallbacks(Choreographer.java:598)
W/System.err(  850):    at android.view.Choreographer.doFrame(Choreographer.java:566)
W/System.err(  850):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781)
W/System.err(  850):    at android.os.Handler.handleCallback(Handler.java:810)
W/System.err(  850):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  850):    at android.os.Looper.loop(Looper.java:189)
W/System.err(  850):    at android.app.ActivityThread.main(ActivityThread.java:5532)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(  850):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(  850):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
W/System.err(  850):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
D/KeyguardSecurityModel(  850): isPinPukOrMeRequiredOfSubId() - simState = ABSENT
D/KeyguardSecurityModel(  850): isPinPukOrMeRequiredOfSubId() - simState = ABSENT
D/AntiTheftManager(  850): getCurrentAntiTheftMode() is called.
D/KeyguardSecurityModel(  850): getSecurityMode() - PW_Quality = 65536
D/LockPatternUtilsCache(  850): havePattern() - cache = true
D/LockPatternUtils(  850): s=true ,L=true ,q=true ,v=false
D/LockPatternUtilsCache(  850): havePattern() - cache = true
V/KeyguardSecurityContainer(  850): showPrimarySecurityScreen(turningOff=false)
D/KeyguardSecurityContainer(  850): showSecurityScreen(Pattern)
D/KeyguardSecurityModel(  850): isPinPukOrMeRequiredOfSubId() - simState = ABSENT
D/KeyguardSecurityModel(  850): isPinPukOrMeRequiredOfSubId() - simState = ABSENT
D/AntiTheftManager(  850): getCurrentAntiTheftMode() is called.

正如您所看到的,有许多匹配项makeExpandedInvisible,但是,我想要仅包含的行的匹配项

I/PhoneStatusBar(  850): makeExpandedInvisible

makeExpandedInvisible在该行的末尾和不是其他行包含makeExpandedInvisible.


查询 -

grep -A 25 -E 'show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible$'

不起作用。

即使是-A 25也不是问题。日志更大,我只包含了一部分。

答案1

使用组内的所有模式:

grep -A 25 -E '(show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible)$'

由于我们使用 来对模式进行分组(),因此它们将被视为一个整体,并且这将匹配该行末尾的三个模式中的任何一个。

以前,在您的命令中grep -A 25 -E 'show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible$',它单独处理三个模式,即在行中的任何位置并且show\(authenticated =仅在行尾处理。onAllPanelsCollapsed\(\)makeExpandedInvisible

结果,它匹配show\(authenticated =任何地方或onAllPanelsCollapsed\(\)任何地方或makeExpandedInvisible行尾。

相关内容