Occurrences of if a value in 24 hr period


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Occurrences of if a value in 24 hr period
# 1  
Old 06-18-2014
Occurrences of if a value in 24 hr period

The following is a sample of the data I am working with:

Code:
ID#___Hour

ID=10008 19
ID=10008 20
ID=10014 19
ID=10014 20
ID=21047 20

Need to get the following output:

Code:
ID#_______0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23

ID=10008    ------------------**---
ID=10014    ------------------**---
ID=21047    -------------------*---


Last edited by Don Cragun; 06-18-2014 at 05:59 PM.. Reason: Add CODE tags.
# 2  
Old 06-18-2014
What have you tried?
# 3  
Old 06-18-2014
Used awk and sed to get the file to the format shown in the previous post, but I am stuck at this point.
# 4  
Old 06-18-2014
As long as your hour values which are <10 are single digits, try this:

Code:
awk 'NF<2 {next}
!($1 in id) {ids[++d]=$1; id[$1]++}
!($2 in hr) {hrs[$2]=$2; hr[$2]++}
            {map[$1,$2]++}
END{
print "ID#_______0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23\n"
    for (x=1;x<=d;x++) {
        printf ids[x] "    "
        for (j=0;j<=23;j++) {
            printf "%s", (map[ids[x],hrs[j]] ? "*" : "-" )
        }
        print ""
    }
}' inputfile


Last edited by pilnet101; 06-18-2014 at 07:37 PM..
This User Gave Thanks to pilnet101 For This Post:
# 5  
Old 06-19-2014
Thank you pilnet101. That works perfectly!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To get the Files between Time Period

All, How to get the list of files through a unix command which exists / created / updated between 8 PM to 11:59 PM from a particular location. Regards Oracle User (3 Replies)
Discussion started by: Oracle_User
3 Replies

2. Shell Programming and Scripting

Add a newline after every period

I need to add a newline after every period. Here is some sample text. The mechanisms for this type of conditioning are probably the same in humans. According to PET scans on young adults, when pairing a stimulus with an airpuff produces a conditioned eye blink, activity increases in the... (4 Replies)
Discussion started by: danbroz
4 Replies

3. Shell Programming and Scripting

How to insert period after each number?

stupid question: trying to use sed to do the following... $ echo '12345' | sed 's/./&./g' 1.2.3.4.5. needed this instead: 1.2.3.4.5 but how? please advise (7 Replies)
Discussion started by: ux4me
7 Replies

4. Shell Programming and Scripting

help to get all dates for given period

i need a text file which contains all dates between given period i.e 01.05.2011 to 12.06.2011 Pls help (1 Reply)
Discussion started by: suryanarayana
1 Replies

5. HP-UX

Grep - specific period

Hi everyone, I want to use grep to search a patern in a folder. But the folder contains millions of files which makes a big delay if I want to search all the files in the folder. I have been trying to use grep to search the last 10 days of all the files. but no success yet! could you advice? ... (2 Replies)
Discussion started by: messi777
2 Replies

6. UNIX for Dummies Questions & Answers

Am confused - The all important . (period) - ????

Hi, My apologies if this question is so trivial ... I guess there really is a room for dummies ... :o Anyway, just wanting to know if someone can please explain what the dot (.) infront of the command or script does and why it works and does not work in the following? ... (1 Reply)
Discussion started by: newbie_01
1 Replies

7. Shell Programming and Scripting

How to get rid of the last period (.)

Hello, I'm able to trim down the log message to "192.168.1.0.", but can't get rid off the last period. Can any one help me on the syntax to get rid of the last period? Basically, I want "192.168.1.0" instead of "192.168.1.0." Thanks, (4 Replies)
Discussion started by: dannytrinh
4 Replies

8. Shell Programming and Scripting

output result (period -1)

hello, I have the following basic script which input the period, but I would like to output is period -1.. how? echo Please input period (yyyymm): read PERIOD OUTPUT=$PERIOD -1 echo " you request period -1 is $OUT" input 200705 output 200704 input 200701 output 200612 The above... (4 Replies)
Discussion started by: happyv
4 Replies

9. Shell Programming and Scripting

record wc -l over 24 hour period

I need to keep track of this output echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l I need to record that count once an hour 24 hours a day and write to a file with the date and time it was run. Any idea on how to do this. (5 Replies)
Discussion started by: csaunders
5 Replies

10. UNIX for Dummies Questions & Answers

Timeout period

How do i increase the timeout period of a telnet session? (4 Replies)
Discussion started by: Nadeem Mistry
4 Replies
Login or Register to Ask a Question