Jump to content


ztag and grep, discovering and printing string

ztag grep

  • Please log in to reply
1 reply to this topic

#1 Elliott Lock

Elliott Lock

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 15 April 2018 - 04:20 PM

Hi all,

I'm running the following command:

p4 -ztag -F "%depotFile%;%rev%;%line%;%rev%" grep -a -n -s -e "Nothing" "//streams/dev/server/ReadMe.txt"

Which produces this:
//streams/dev/server/ReadMe.txt;3;1;3
//streams/dev/server/ReadMe.txt;1;1;1

This is great but I'm missing one bit of information which is I'd like to see the string for the line in question. For example, running without ztag as:
p4 grep -a -n -s -e "Nothing" "//streams/dev/server/ReadMe.txt"

Would produce:

//streams/dev/server/ReadMe.txt#3:1:Nothing
//streams/dev/server/ReadMe.txt#1:1:Nothing to see here :)

It's the last section I require.

Many Thanks

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 588 posts

Posted 16 April 2018 - 01:17 AM

Run the command without the -F to see all the fields (to see the components of the standard message rather than tagged mode, use "-e"):


C:\Perforce\test>p4 -e grep -an -e asdf foo
info: //stream/main/foo#2:1:asdfasdf
code0 369105429 (sub 533 sys 6 gen 0 args 6 sev 1 uniq 6677)
... code0 369105429
... fmt0 %depotFile%#%depotRev%%separator1%%linenumber%%separator2%%linecontent%
... depotFile //stream/main/foo
... depotRev 2
... separator1 :
... linenumber 1
... separator2 :
... linecontent asdfasdf

The piece you want is called "linecontent", so do:

p4 -F "%depotFile%;%depotRev%;%linenumber%;%linecontent%" grep -a -n -s -e "Nothing" "//streams/dev/server/ReadMe.txt"


Although this is basically identical to the standard message -- maybe you'd rather just do this?

p4 grep -a -n -s -e "Nothing" "//streams/dev/server/ReadMe.txt"






Also tagged with one or more of these keywords: ztag, grep

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users