1

I am trying to do an extended grep on Android logs. However, I am not able to match the anchors for it.

Here's my query -

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

I want to match either

  • show(authenticated = or
  • onAllPanelsCollapsed() or
  • makeExpandedInvisible at the end of the line.

However, the output I am always getting is

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)

Even though I am using an extended grep, I am not able to match makeExpandedInvisible but the other patterns are working fine.


EDIT

Match for -

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

is

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.

As you can see there are a number of matches for makeExpandedInvisible, however, I want the match for the line that only contains

I/PhoneStatusBar(  850): makeExpandedInvisible

i.e. makeExpandedInvisible at the end of the line and NOT the other lines containing makeExpandedInvisible.


The query -

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

does not work.

Even the -A 25 is not a problem. The logs are even bigger, I have included only a part.

  • Is that perhaps just showing up because it's in the 25 lines after the show(authenticated = and not actually the line that's being matched itself? – Eric Renouf Apr 16 '15 at 14:53
  • Any one of three at the end of the line? – heemayl Apr 16 '15 at 14:55
  • @Eric Here 'makeExpandedInvisible' not matching is fine. There is another case where it is at the start of line and is not matching. – yadav_vi Apr 16 '15 at 15:02
  • I'm not clear I think on what the problem was. It sounded to me like the output you showed is unexpected and you though that the makeExpandedInvisible should not have been matched because it's not at the end of the line. If the output you display is not the problem, could you show the output that you do think is a problem – Eric Renouf Apr 16 '15 at 15:16
1

Use all patterns inside a group:

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

As we have grouped the patterns using (), they will be treated as a whole and this will match any one of the three patterns at the end of the line.

Previously, in your command grep -A 25 -E 'show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible$', it is treating three patterns individually i.e. show\(authenticated = and onAllPanelsCollapsed\(\) anywhere in the line and makeExpandedInvisible only at the end of the line.

As a result, it was matching show\(authenticated = anywhere OR onAllPanelsCollapsed\(\) anywhere OR makeExpandedInvisible at the end of the line.

  • I want ONLY makeExpandedInvisible to be at the end of line. Other patterns can be found anywhere in the line. With the solution that you've given all the patterns are searched to be at the end of line. – yadav_vi Apr 17 '15 at 5:34
  • I asked you about this in the comment :) ..anyway your command seems fine to me as far as what have you posted is concerned..it would be great if you could add a chunk of original text where this is failing. – heemayl Apr 17 '15 at 8:53
  • I have edited the question with more logs and details. – yadav_vi Apr 17 '15 at 14:02
  • @yadav_vi: I have copied your newly added file contents and run it without -A 25 and i was getting the perfect result..only logical colclusion could be -A 25..also could you please run the grep without -A 25 and check the output..add a chunk of file where the command is faining, not the output.. – heemayl Apr 17 '15 at 19:27
  • You are right, reducing the value for -A to 10 worked, grep -A 10 -E '(show\(authenticated = |onAllPanelsCollapsed\(\)|makeExpandedInvisible$)' gives proper results. – yadav_vi Apr 20 '15 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.