08-27-2008
hello....
this is what i deed....
I donīt know if itīs the best idea...but works....
your sugestion do something like this?
BEGIN {
FS="|";
c1 = -1;
c4 = -1;
c5 = -1;
c8 = 0;
time = 0;
}
{
if (($1 == c1) && ($4 == c4) && ($5 == c5))
{
# accumulate value $8
if ($7 <= time)
{
c8 = c8 + $8
# updates variable time
time = $7 + $8 + 2
}
#write to output
if ($9 == 4)
{
print c1"|"c2"|"c3"|"c4"|"c5"|"c6 "|"c7 "|"c8"|1|"c10"|"c11"|"c12"|"c13"|"c14"|"c15 >> file_complete
close(file_complete)
#restart variables
time = 0
c8 = 0
next
}
}
else
{ # the record don't have the same key has the last record
if (c1 == -1)#when reads the 1st line of the file only keeps the relevant fields of the first record
{
if ($9 == 2) #save the fields from the beginning of the call, to put in output
{
c1 = $1
c2 = $2
c3 = $3
c4 = $4
c5 = $5
c6 = $6
c7 = $7
c8 = $8
c10 = $10
c11 = $11
c12 = $12
c13 = $13
c14 = $14
c15 = $15
time = $7 + $8 + 2
next
}
}
if (c1 != -1)#print output of the previous
{
print c1"|"c2"|"c3"|"c4"|"c5"|"c6"|"c7"|"c8"|1|"c10"|"c11"|"c12"|"c13"|"c14"|"c15 >> file_complete
close(file_complete)
# save the current record if is the beginning of the call
if ($9 == 2)
{ # save the fields from the beginning of the call, to put in output
c1 = $1
c2 = $2
c3 = $3
c4 = $4
c5 = $5
c6 = $6
c7 = $7
c8 = $8
c10 = $10
c11 = $11
c12 = $12
c13 = $13
c14 = $14
c15 = $15
time = $7 + $8 + 2
}
}
}
}
END {
#print the output for the case that not caught the last registration with closing ($ 9 = 4, but caught with $ 9 = 3)
if ($9 == 3)
{
print c1 "|" c2 "|" c3 "|" c4 "|" c5 "|" c6 "|" c7 "|" c8 "|1|" c10 "|" c11 "|" c12 "|" c13 "|" c14 "|" c15 >> file_complete
close(file_complete)
}
}
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have been looking for info on how to aggregate 2 ore 3 NIC's into into one big pipe. Any advice would be appreciated.
-Chuck (4 Replies)
Discussion started by: 98_1LE
4 Replies
2. Shell Programming and Scripting
Hi,
Is it possible to find the total number of records processed by awk at begining.
NR gives the value at the end. Is there any variable available to find the value at the begining?
Thanks
----------
Suman (1 Reply)
Discussion started by: suman_jakkula
1 Replies
3. UNIX Desktop Questions & Answers
Hello how are you, i have a question i have a file ale.log and i want to agregate a title and later a space when the text is over and put another title (when the text is over) how can i do this? thank you
Example
Last ------>(Title) i want to agregate
pupu pupu pupu pupu... (1 Reply)
Discussion started by: enkei17
1 Replies
4. IP Networking
Hi
I have a question related to load balancing.I have two separate internet connections with 2Mbps speed and i would like to aggregate this two connections intro one connection with 4Mbps.Is it possible to do that, to put a Linux or Unix machine as a gateway?I read some stuff to split the... (3 Replies)
Discussion started by: tafil
3 Replies
5. Shell Programming and Scripting
file 1:
70|236|PPS|0501011818|mms|20090706|001452|00000024|2|0000000000000000|00000|0000000000|0000000000|40948000|1
70|236|PPS|0501020076|mms|20090705|204408|00000019|2|0000000000000000|00000|0000000000|0000000000|40947930|1... (3 Replies)
Discussion started by: magedfawzy
3 Replies
6. Shell Programming and Scripting
Hi,
I have an awk code that reads an input file, checks the 4th column and tells if its fine.
#!/bin/ksh
{ if ($4 == 0)
print "fine"
else
print "some problem" }' FILENAME
My problem is that, I dont want to check the first 3 and last 3 lines.
This can be hard coded by using BEGIN and END... (9 Replies)
Discussion started by: gotam
9 Replies
7. Shell Programming and Scripting
Hi experts,
I need an help on the task below.
INPUT: values separated by the tab,first row is the header
20110609 AS A 300.5000
20110609 AS R 200.5000
20110609 BR A 111.5000
20110609 BR R 222.5000
20110610 AS A 100.5500
20110610 AS ... (2 Replies)
Discussion started by: hernand
2 Replies
8. Shell Programming and Scripting
Hi,
To be honest, I am really impressed and amazed at the pace I find solutions for un-solved coding mysteries in this forum.
I have a file like this
input1.txt
x y z 1 2 3
a b c 4 -3 7
k l m n 0 p
1 2 a b c 4
input2
x y z 9 0 -1
a b c 0 6 9
k l m 8 o p
1 2 a f x 9
Output... (9 Replies)
Discussion started by: jacobs.smith
9 Replies
9. Solaris
hi all,
i start with solaris 11 and i am disapointed by the change on ip managing.
i want to set a ipmp over tow aggregate but i dont find any doc and i am lost with the new commande
switch1
net0 aggregate1 |
net1 aggregate1 |-----|
|... (1 Reply)
Discussion started by: sylvain
1 Replies
10. Shell Programming and Scripting
Guys,
I need to roll up data within the file and build a new file with the output and the same format as the original file.
The data should be rolled up for each unique combination of ord,line,date and hour.. The last column appr is always " "
Below is the format
Original File:
... (8 Replies)
Discussion started by: venky338
8 Replies
eof(3tcl) Tcl Built-In Commands eof(3tcl)
__________________________________________________________________________________________________________________________________________________
NAME
eof - Check for end of file condition on channel
SYNOPSIS
eof channelId
_________________________________________________________________
DESCRIPTION
Returns 1 if an end of file condition occurred during the most recent input operation on channelId (such as gets), 0 otherwise.
ChannelId must be an identifier for an open channel such as a Tcl standard channel (stdin, stdout, or stderr), the return value from an
invocation of open or socket, or the result of a channel creation command provided by a Tcl extension.
EXAMPLES
Read and print out the contents of a file line-by-line:
set f [open somefile.txt]
while {1} {
set line [gets $f]
if {[eof $f]} {
close $f
break
}
puts "Read line: $line"
}
Read and print out the contents of a file by fixed-size records:
set f [open somefile.dat]
fconfigure $f -translation binary
set recordSize 40
while {1} {
set record [read $f $recordSize]
if {[eof $f]} {
close $f
break
}
puts "Read record: $record"
}
SEE ALSO
file(3tcl), open(3tcl), close(3tcl), fblocked(3tcl), Tcl_StandardChannels(3tcl)
KEYWORDS
channel, end of file
Tcl 7.5 eof(3tcl)