I need help on figuring out a way to filter some data that I get back from an API. Im able to get all the data that Im looking for but I would like to know a way for me to filter it better. The data that Im getting back is basically 2 rows of data as seen here.
Row 1 Row 2
ID|999MOB001|Last Contact>8 d 5 h
ID|999test13|Last Contact>2 h 0 m
ID|testipad1|Last Contact>42 m 7 s
As you can see in Row 2 I get back data that is showing the last time it was contacted.
What Im looking to get done is to get back only lines that have a specific data value that is greater than say 2 d(ays). Below is a copy of my script that Im running. So any help in what I can change to get back only the data that is older than 2 days would be helpful. From what I have been looking at I might have to use perl against my output.txt file to help sort but I wanted to see if there was a way to get this done with out using perl.
Now I have a new problem how would I set the sort to show any number of days like if I wanted to show data that was 14 D or older? Also the another issue that Im running into is that Im not showing any days that are the number 10. There are some in the file but they do not show up when I pull data that is greater than or equal to 2 days.
M105POD071,CCQML69HFMJF,53 d 2 h,6476BABC3B68,
633MOB43,DMPNRXUQG5VJ,9 d 13 h,908D6C582E1E,
103MOB14,DQTNP2HEG5VJ,17 d 21 h,2C1F23014C4A,
M153POD071,CCQLX7QUF4K1,177 d 12 h,F82793A56130,
My current code with the changes that I needed to make. But how would I edit this to pull greater than or equal to 14 d from $3???
Thank you this is helpful but still not 100% what I need.
This brings back data that has h(hours) and m(inutes) I need to get data that is only for x-number of d(ays) and this is also stopping at 100 I need it to go past 100 to like 999 d(ays)
403mob16,DMPNPTV2G5VJ,19 h 11 m,2C1F2305E136,
999MOB001,DMRNL7EHG5VT,27 d 5 h,24A0741E65B8,
621MOB93,DMPNRPB4G5VJ,35 m 7 s,908D6C1B2D06,
M059POD071,C3TJ74NQDNQW,100 d 16 h,BC677843C4C7,
124mob7,iOS 8.3,iPad Air 2,6.3,DMPNRMTHG5VJ,1 h 4 m,908D6C582D84
M215POD2,iOS 8.3,iPod touch 5th gen,6.2,CCQPM37YFMJF,10 d 22 m,48E9F12FD989
M155POD072,iOS 8.2,iPod touch 5th gen,6.3,CCQM129ZF4K1,31 d 3 h,F827939F3D33
M115POD053,iOS 8.3,iPod touch 5th gen,6.3,CCQMCCTGFMJF,3 d 0 h,B03495D4AE6F
awk -F'[, ]' '$9=="d" && $6>=14'
Hi Guys like my name says I'm still struggling with this. The last code I had worked great but now they want more data from our devices and now I'm not able to get back my data by filtering it the same way. I made a change to the awk command to go to the 9th column which I think is correct but I have also tried it with 10 or 11 and I get different results. Any help as to why I'm now not able to get back the data that I want and sort it correctly?
I think my issue is that I have different data in column 3. Sometimes its 2 words and 1 space, 3 words and 2 spaces or 4 words and 3 spaces. Would I need a while loop or something like that? If so can you provide an example?
This is a nice piece of code THANKS! It showed me that I sometimes have 12 fields or 13 or 14. I would guess that this is where my problem is. This is where I now think a while loop or something might be what I need to address the variance in the column???
Exactly. You've got (at least) two options here - get the field relative to line end (= NF), if that is constant, or, if the file has a constant number of comma separated fields, use only comma as FS, and then split the field with the time data in it.
I do but I want to be able to sort off the number of d(ays). So if something is older than 14 days I can get back just the lines that are >=14 in that column.