Grep help
-
I have one text file which needs to grep with ticket number only. I have two kinds of ticket number in it. the ticket starts with V and D.after this numeric values are there for each tickets.how to grep that values only ?
I have tried this command which does not work
cat test.txt | grep "D[:digit:]{8}" grep: character class syntax is [[:space:]], not [:space:] cat test.txt | grep '\b[a-zA-Z]{1}[0-9]{8}\b' -
cat test.txt | grep [A-Z]{1}\d{8} zsh: no matches found: [A-Z]{1}d{8} -
I'm not sure that I understand? Can you show a sample of five or six different ticket numbers?
-
@scottalanmiller said in Grep help:
I'm not sure that I understand? Can you show a sample of five or six different ticket numbers?
example the txt file have
D00000000
D00000001
D00000002
D00000003Theses are the tickets numbers which is available in the txt file where i am in need to grep the ticket number only from the txt file
-
@laksh1999 Because you are attempting to use regular expressions with a tool that does not know WTF those are.
man grepis a wonderful thing.
If you are going to keep asking questions, you should learn to do a little basic reading.but to spoon feed you...
# return lines with an A or D followed by 8 digits. grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]Sample:
stuff 1 A00000000 more stuff 1 stuff 2 B0000001 more stuff 2 stuff 3 C00000002 more stuff 3 stuff 4 D00000003 more stuff 4 stuff 5 E00000002 more stuff 5Result:
cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]] stuff 1 A00000000 more stuff 1 stuff 4 D00000003 more stuff 4 -
@jaredbusch said in Grep help:
@laksh1999 Because you are attempting to use regular expressions with a tool that does not know WTF those are.
man grepis a wonderful thing.
If you are going to keep asking questions, you should learn to do a little basic reading.but to spoon feed you...
# return lines with an A or D followed by 8 digits. grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]Sample:
stuff 1 A00000000 more stuff 1 stuff 2 B0000001 more stuff 2 stuff 3 C00000002 more stuff 3 stuff 4 D00000003 more stuff 4 stuff 5 E00000002 more stuff 5Result:
cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]] stuff 1 A00000000 more stuff 1 stuff 4 D00000003 more stuff 4This does not work for me.I have tried this as well.I am not asking for spoon feeding for the same.
i have the json file with "id" ="D00000000" and "id"="V000000000" and i too have some id with encrypted data.i need to get only the D and V numbers and arranged in order from the json file which i have downloaded as .txt
-
-
@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.
-
@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:]] -
@jaredbusch said in Grep help:
@laksh1999 said in Grep help:
json file
Then use
jsontools FFS.
man jqcat wtf.txt | jq *.idcat newdata.txt | jq *.id zsh: no matches found: *.id -
@laksh1999 said in Grep help:
@jaredbusch said in Grep help:
@laksh1999 said in Grep help:
json file
Then use
jsontools FFS.
man jqcat wtf.txt | jq *.idcat newdata.txt | jq *.id zsh: no matches found: *.idYou didn't bother to read the
manfile.. i pulled that out of my ass from memory...the correct syntax is
jq '.idbut as this point I doubt you have the data you think you have in your text file.
-
@jaredbusch said in Grep help:
the correct syntax is
jq '.id'I'm also assuming that
idis one of thejsonkeys based on your first post. -
@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 EOFthen
cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
-
@jaredbusch said in Grep help:
@jaredbusch said in Grep help:
the correct syntax is
jq '.idI'm also assuming that
idis one of thejsonkeys 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
-
@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 EOFthen
cat test.txt | grep [AD][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]
This worked for me now
cat test.txt | grep '[V][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]' -
@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 fuckingjsontools.jqis extremely powerful. Use it to correctly query yourjsondata to get the result you need. -