ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Grep help

    IT Discussion
    3
    17
    885
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch @Laksh1999
      last edited by

      @laksh1999 said in Grep help:

      json file

      Then use json tools FFS.
      man jq

      cat wtf.txt | jq *.id
      
      L 1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch @Laksh1999
        last edited by

        @laksh1999 said in Grep help:

        This does not work for me.

        I would love to see proof because I just showed you proof it does work.

        L 1 Reply Last reply Reply Quote 0
        • L
          Laksh1999 @JaredBusch
          last edited by

          @jaredbusch said in Grep help:

          @laksh1999 said in Grep help:

          This does not work for me.

          I would love to see proof because I just showed you proof it does work.

           cat newdata.txt | grep [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]] 
          zsh: no matches found: [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
          
          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • L
            Laksh1999 @JaredBusch
            last edited by

            @jaredbusch said in Grep help:

            @laksh1999 said in Grep help:

            json file

            Then use json tools FFS.
            man jq

            cat wtf.txt | jq *.id
            
            cat newdata.txt | jq *.id
            zsh: no matches found: *.id
            
            JaredBuschJ 1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch @Laksh1999
              last edited by JaredBusch

              @laksh1999 said in Grep help:

              @jaredbusch said in Grep help:

              @laksh1999 said in Grep help:

              json file

              Then use json tools FFS.
              man jq

              cat wtf.txt | jq *.id
              
              cat newdata.txt | jq *.id
              zsh: no matches found: *.id
              

              You didn't bother to read the man file.. i pulled that out of my ass from memory...

              the correct syntax is jq '.id

              but as this point I doubt you have the data you think you have in your text file.

              JaredBuschJ 1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch @JaredBusch
                last edited by JaredBusch

                @jaredbusch said in Grep help:

                the correct syntax is jq '.id'

                I'm also assuming that id is one of the json keys based on your first post.

                L 1 Reply Last reply Reply Quote 0
                • JaredBuschJ
                  JaredBusch @Laksh1999
                  last edited by

                  @laksh1999 said in Grep help:

                  @jaredbusch said in Grep help:

                  @laksh1999 said in Grep help:

                  This does not work for me.

                  I would love to see proof because I just showed you proof it does work.

                   cat newdata.txt | grep [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]] 
                  zsh: no matches found: [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
                  

                  no one knows WTF you have in newdata.txt....

                  cat > test.txt << EOF
                  stuff 1 A00000000 more stuff 1
                  stuff 2 B00000001 more stuff 2
                  stuff 3 C00000002 more stuff 3
                  stuff 4 D00000003 more stuff 4
                  stuff 5 E00000002 more stuff 5
                  EOF
                  

                  then

                  cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
                  

                  3a3ec045-a5a6-4a91-aeeb-a9a0e5aa4ff8-image.png

                  L 1 Reply Last reply Reply Quote 0
                  • L
                    Laksh1999 @JaredBusch
                    last edited by

                    @jaredbusch said in Grep help:

                    @jaredbusch said in Grep help:

                    the correct syntax is jq '.id

                    I'm also assuming that id is one of the json keys based on your first post.

                    There are more id values are there in the txt file

                    Example)
                    This id value example is only for the 1 tickets
                    "id"="D00000000"
                    "id" ="V00000000"
                    "id"="eeeeeee-eeeeee-eeeee-eeeee"
                    "id"="eadsga-ereagag"

                    i just want to grep only D0000000 and V000000 values for each tickets.There are around 5000 tickets are there and each for more id for one ticket

                    JaredBuschJ 1 Reply Last reply Reply Quote 0
                    • L
                      Laksh1999 @JaredBusch
                      last edited by

                      @jaredbusch said in Grep help:

                      @laksh1999 said in Grep help:

                      @jaredbusch said in Grep help:

                      @laksh1999 said in Grep help:

                      This does not work for me.

                      I would love to see proof because I just showed you proof it does work.

                       cat newdata.txt | grep [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]] 
                      zsh: no matches found: [V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
                      

                      no one knows WTF you have in newdata.txt....

                      cat > test.txt << EOF
                      stuff 1 A00000000 more stuff 1
                      stuff 2 B00000001 more stuff 2
                      stuff 3 C00000002 more stuff 3
                      stuff 4 D00000003 more stuff 4
                      stuff 5 E00000002 more stuff 5
                      EOF
                      

                      then

                      cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
                      

                      3a3ec045-a5a6-4a91-aeeb-a9a0e5aa4ff8-image.png

                      This worked for me now

                      cat test.txt | grep '[V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]'
                      
                      1 Reply Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch @Laksh1999
                        last edited by

                        @laksh1999 said in Grep help:

                        want to grep

                        no you don't.

                        FFS how many times do I have to tell you.

                        Your data is json, use fucking jsontools.

                        jq is extremely powerful. Use it to correctly query your json data to get the result you need.

                        1 Reply Last reply Reply Quote 1
                        • JaredBuschJ
                          JaredBusch
                          last edited by

                          https://www.cloudsavvyit.com/1877/how-to-work-with-json-on-the-command-line/

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post