awk to subtract from values in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk to subtract from values in file
# 1  
Old 10-12-2015
awk to subtract from values in file

data.txt:

Code:
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,734--734
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,736--736
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742

I'm using the below code to get specific values:

Code:
gawk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, nodatetime_mq_conn_open_error  | gawk -F"," '/Oct 10 04.*2015,/,0 {print $10"-"$4"_"$11}'

when i run the above awk code, i get this:

Code:
0-1444665949_733--734
0-1444666249_734--734
0-1444666549_734--735
0-1444666849_735--735
0-1444667149_735--735
0-1444667449_735--735
0-1444667749_735--736
0-1444668049_736--736
2-1444668349_736--742
0-1444668649_742--742

What i need to do now, is, i want to be able to subtract the two numbers at the end so that when i run the awk code, it gives me the diference between the two numbers. something like this:

Code:
0-1444665949_1
0-1444666249_0
0-1444666549_1
0-1444666849_0
0-1444667149_0
0-1444667449_0
0-1444667749_1
0-1444668049_0
2-1444668349_6
0-1444668649_0

also, i want to be able to get the difference between values on two consecutive lines. for instance,

Code:
0,mq_conn_open_error,1444668049,736,/PROD/GAP/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,736--736
2,mq_conn_open_error,1444668349,742,/PROD/GAP/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742

i want to have a separate awk command like the one above that will subtract the bolded value of a specific column in a log line from the same column in the line before it. so basically, the awk code would have to read the output given to it 2 lines at a time and do the substraction, then move on to the next two lines. hope this makes sense.

Last edited by SkySmart; 10-12-2015 at 02:29 PM..
# 2  
Old 10-12-2015
Hello SkySmart,

Could you please try following.
Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){split($NF, B,"--");print $1 "-" $3 "_" B[2]-B[1]}}'  Input_file

Output will be as follows.
Code:
0-1444667449_0
0-1444667749_1
0-1444668049_0
2-1444668349_6
0-1444668649_0

NOTE: In this example input you have shown dates which are 12 Oct so only I have taken that in my code, you can put it as per your need.

EDIT: Adding a non one-liner form of solution now for same.
Code:
awk -F, '{
                A=strftime("%a %b %d %T %Y,%s",$3);
                if(A ~ /Oct 12.*2015/){
                                                        split($NF, B,"--");
                                                        print $1 "-" $3 "_" B[2]-B[1]
                                      }
         }
        '  Input_file

Thanks,
R. Singh

Last edited by RavinderSingh13; 10-12-2015 at 02:37 PM.. Reason: Added a non one liner form of soltion now.
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 10-12-2015
For your second requirement, try
Code:
awk 'NR>1 {print $8 - last} {last = $8} END {print $8 - last}' FS="," file
0
85
0
0
0
85
0
566
0
0

This User Gave Thanks to RudiC For This Post:
# 4  
Old 10-13-2015
Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){split($NF, B,"--");print $1 "-" $3 "_" B[2]-B[1]}}'  Input_file

The above command works beautifully. however, i'd like for it to pull out all records it finds in the log from the point the search pattern is found, to the end of file.

right now, it only shows the line containing the search pattern.

Code:
-sh-4.1$ 
-sh-4.1$ awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12 13:55.*2015/){split($NF, B,"--");print $1 "-" $3 "_" B[2]-B[1]} }' input_file.txt
0-1444683349_0
-sh-4.1$ 
-sh-4.1$


Last edited by SkySmart; 10-13-2015 at 06:43 PM..
# 5  
Old 10-14-2015
Hello SkySmart,

If I understood correctly your requirement, you need to print all the records from the point where first match happens for example Oct 12.*2015 in this example, you can mention dates as per your need. Following may help you in same then.
Let's say we have following Input_file:
Code:
cat Input_file
0,mq_conn_open_error,1744665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1644666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,734--734
0,mq_conn_open_error,1844666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1944666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,2244667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,736--736
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,734--734
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,736--736
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,734--734
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1544667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1644667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,735--735
0,mq_conn_open_error,1744667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736
0,mq_conn_open_error,1844668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,736--736
2,mq_conn_open_error,1944668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742
0,mq_conn_open_error,2044668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742

So if you will see the dates and times in Input_file it will look as follows.
Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);print A}' Input_file

Code:
Mon Apr 14 17:25:49 2025,1744665949
Sat Feb 12 06:44:09 2022,1644666249
Thu Jun 15 03:22:29 2028,1844666549
Sat Aug 16 13:14:09 2031,1944666849
Sat Feb 16 17:39:09 2041,2244667149
Mon Oct 12 12:30:49 2015,1444667449
Mon Oct 12 12:35:49 2015,1444667749
Mon Oct 12 12:40:49 2015,1444668049
Mon Oct 12 12:45:49 2015,1444668349
Mon Oct 12 12:50:49 2015,1444668649
Mon Oct 12 12:05:49 2015,1444665949
Mon Oct 12 12:10:49 2015,1444666249
Mon Oct 12 12:15:49 2015,1444666549
Mon Oct 12 12:20:49 2015,1444666849
Mon Oct 12 12:25:49 2015,1444667149
Mon Oct 12 12:30:49 2015,1444667449
Mon Oct 12 12:35:49 2015,1444667749
Mon Oct 12 12:40:49 2015,1444668049
Mon Oct 12 12:45:49 2015,1444668349
Mon Oct 12 12:50:49 2015,1444668649
Mon Oct 12 12:05:49 2015,1444665949
Mon Oct 12 12:10:49 2015,1444666249
Mon Oct 12 12:15:49 2015,1444666549
Mon Oct 12 12:20:49 2015,1444666849
Wed Dec 12 21:12:29 2018,1544667149
Sat Feb 12 07:04:09 2022,1644667449
Mon Apr 14 17:55:49 2025,1744667749
Thu Jun 15 03:47:29 2028,1844668049
Sat Aug 16 13:39:09 2031,1944668349
Mon Oct 16 23:30:49 2034,2044668649

So as you can see above when it will match date Oct 12.*2015 it will print from there to till rest of the lines.
Following code may help then for same.
Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){Q=1};if(Q){split($NF, B,"--");print $1 "-" $3 "_" B[2]-B[1]}}'  Input_file

Output will be as follows then.
Code:
0-1444667449_0
0-1444667749_1
0-1444668049_0
2-1444668349_6
0-1444668649_0
0-1444665949_1
0-1444666249_0
0-1444666549_1
0-1444666849_0
0-1444667149_0
0-1444667449_0
0-1444667749_1
0-1444668049_0
2-1444668349_6
0-1444668649_0
0-1444665949_1
0-1444666249_0
0-1444666549_1
0-1444666849_0
0-1544667149_0
0-1644667449_0
0-1744667749_1
0-1844668049_0
2-1944668349_6
0-2044668649_0

Kindly do let me know if you have any queries on same.

Thanks,
R. Singh

Last edited by RavinderSingh13; 10-14-2015 at 02:33 AM.. Reason: Added an example in solution
This User Gave Thanks to RavinderSingh13 For This Post:
# 6  
Old 10-14-2015
Quote:
Originally Posted by RavinderSingh13
Hello SkySmart,

Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){Q=1};if(Q){split($NF, B,"--");print $1 "-" $3 "_" B[2]-B[1]}}'  Input_file

Thanks,
R. Singh
Your command worked magnificently! thank you.

one final question.

i have this command (provided above by RudiC to address my second problem of subtracting values on two different consecutive lines):

Code:
gawk 'NR>1 {print $8 - last"-"$3"_"$8"--"last","$10} {last = $8} END {print $8 - last"-"$3"_"$8"--"last","$10}' FS="," Input_file

It works. but, i want it to pull out all records found in this file, from a certain point, to the end of the file, then perform the subtractions.

so, i know it will involve something like this:

Code:
gawk 'NR>1 {A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12 03:55.*2015/){Q=1};if(Q){split($NF, B,"--") {print $8 - last"-"$3"_"$8"--"last","$10} {last = $8} END {print $8 - last"-"$3"_"$8"--"last","$10}' FS="," Input_file

but this isn't working.

Last edited by SkySmart; 10-14-2015 at 05:25 PM..
# 7  
Old 10-14-2015
Hello SkySmart,

Let's say we have following Input_file as follows.
Code:
0,mq_conn_open_error,1744665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1644666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,714--734
0,mq_conn_open_error,1844666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1944666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,715--735
0,mq_conn_open_error,2244667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,705--735
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,705--735
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,702--736
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,705--736
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,706--742
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,711--742
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,722--734
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,723--734
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,727--735
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,725--735
0,mq_conn_open_error,1444667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,729--735
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,730--735
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,733--736
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,719--736
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,700--742
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,702--742
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,700--734
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,733--735
0,mq_conn_open_error,1544667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,722--735
0,mq_conn_open_error,1644667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,720--735
0,mq_conn_open_error,1744667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736
0,mq_conn_open_error,1844668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,733--736
2,mq_conn_open_error,1944668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742
0,mq_conn_open_error,2044668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742

Following the code which may help in same then.
Code:
awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){Q=1};if(Q){split($NF, B,"--");print B[2]-B[1]}}' Input_file

Output will be as follows.
Code:
30
34
31
36
31
12
11
8
10
6
5
3
17
42
40
34
1
1
2
13
15
1
3
6
0

EDIT: Adding a command by which we can get the respective line and difference too.
Code:
 awk -F, '{A=strftime("%a %b %d %T %Y,%s",$3);if(A ~ /Oct 12.*2015/){Q=1};if(Q){split($NF, B,"--");print $0  OFS B[2]-B[1]}}'  Input_file

Output will be as follows.
Code:
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,705--735 30
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,702--736 34
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,705--736 31
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,706--742 36
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,711--742 31
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,722--734 12
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,723--734 11
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,727--735 8
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,725--735 10
0,mq_conn_open_error,1444667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,729--735 6
0,mq_conn_open_error,1444667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,730--735 5
0,mq_conn_open_error,1444667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,733--736 3
0,mq_conn_open_error,1444668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,719--736 17
2,mq_conn_open_error,1444668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,700--742 42
0,mq_conn_open_error,1444668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,702--742 40
0,mq_conn_open_error,1444665949,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,700--734 34
0,mq_conn_open_error,1444666249,734,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62022,0,733--734 1
0,mq_conn_open_error,1444666549,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,734--735 1
0,mq_conn_open_error,1444666849,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,733--735 2
0,mq_conn_open_error,1544667149,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,722--735 13
0,mq_conn_open_error,1644667449,735,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62107,0,720--735 15
0,mq_conn_open_error,1744667749,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,735--736 1
0,mq_conn_open_error,1844668049,736,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62192,0,733--736 3
2,mq_conn_open_error,1944668349,742,/PROD/G/cicsitlp/sys/unikixmain.log,72K,mq_conn_open_error,62758,2,736--742 6
0,mq_conn_open_error,2044668649,742,/PROD/G/cicsitlp/sys/unikixmain.log,64K,mq_conn_open_error,62758,0,742--742 0

Thanks,
R. Singh

Last edited by RavinderSingh13; 10-14-2015 at 11:36 PM.. Reason: Added some explaination to solution
This User Gave Thanks to RavinderSingh13 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Subtract millisecond Timestamps with awk

Hello, am not able to subtract timestamps in milliseconds. I extract the timestamp as a string, and then try to subtract the two, but since it is a string, system just outputs 0 awk -F"," 'substr($1,0,13) - substr($2,0,013)' File where $1 and $2 are the timestamps in the format... (4 Replies)
Discussion started by: sidnow
4 Replies

2. Shell Programming and Scripting

awk to look up values in File 2 from File 1, & printingNth field of File1 based value of File2 $2

I have two files which are the output of a multiple choice vocab test (60 separate questions) from 104 people (there are some missing responses) and the question list. I have the item list in one file (File1) Item,Stimulus,Choice1,Choice2,Choice3,Choice4,Correct... (5 Replies)
Discussion started by: samonl
5 Replies

3. Programming

Subtract values based on records

Hi Guys, I am having below tables in oracle T1 ID F_TYPE F_AMT DATE_COL 1 F 6 11-Feb-16 1 D 2 11-Feb-16 1 D 2 11-Feb-16 1 F 6 11-Feb-16 1 F 2 12-Mar-16 1 D 3 12-Mar-16 1 F 4 10-Apr-16 1 F 4 11-Apr-16 1 D 1 11-Apr-16 T2 ID START_DATE END_DATE F_ID FLAG... (0 Replies)
Discussion started by: rohit_shinez
0 Replies

4. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

5. UNIX for Dummies Questions & Answers

awk to add/subtract an integer to/from each entry in columns?

---------- Post updated at 01:58 PM ---------- Previous update was at 01:48 PM ---------- For some reason my question is not getting printed. Here are the details: Greetings. I would like to add/subtact an integer to/from two columns of integers. I feel like this should be easy using awk... (3 Replies)
Discussion started by: Twinklefingers
3 Replies

6. Shell Programming and Scripting

Add values in 2 columns and subtract from third

Hi All, I have a file with thousands of lines in the following format, where Field1=First 8 characters Field2-9-16 characters Field3=17-26 characters I need to add Field 1 and Field2 and subtract the result from Field 3. Field3=Field3 - (Field1 + Field2) 0012.00 0010.00 0001576.53... (4 Replies)
Discussion started by: nua7
4 Replies

7. Shell Programming and Scripting

Compare & subtract lines in files by column using awk.

I have two files with similar column pattern as given below : 2 sample lines from file1 are given below. 18 12630 . G T 49.97 . AC=2;AF=1.00;AN=2;DP=3;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ=60.00;MQ0=0;NDA=1;QD=16.66;SB=-0.01 GT:AD:DP:GQ:PL ... (2 Replies)
Discussion started by: vaibhavvsk
2 Replies

8. Shell Programming and Scripting

add and subtract specific row using awk

Hi Folks I have tried awk command to conditionally add or subtract value from specific row in a file. The test file looks like: # cat test.txt cont x y Max 0.3 0.9 Min 0.2 0.9 diff 0.1 0 # awk '{for (i=2; i <=NF; i++) if ($i== "0") $i=$i+0.2; print}' test.txt Output: cont... (1 Reply)
Discussion started by: dixits
1 Replies

9. Shell Programming and Scripting

Subtract field values

I've got a long logfile of the form network1:123:45:6789:01:234:56 network2:12:34:556:778:900:12 network3:... I've got a similar logfile from a week later with different values for each of the fields eg network1:130:50:6800:10:334:66 network2:18:40:600:800:999:20 network3:... ... (5 Replies)
Discussion started by: Yorkie99
5 Replies

10. Shell Programming and Scripting

AWK solution to subtract multiple columns of numbers

Hope somebody is happy. NR==1 { num_columns=split( $0, menuend ); next; } { split( $0, substrend ); for ( i=1; i<=NF; i++ ) { minuend -= substrend; } } END { print "Result:"; for ( i=1; i<=num_columns; i++ ) { printf(... (3 Replies)
Discussion started by: awkward
3 Replies
Login or Register to Ask a Question