{
for (i=1;i<=NF;i++) {
if ($i==1) {
for (j=1;j<=4;j++) {
ones=0;
for (k=(i+j-4);k<=(i+j-1);k++) {
if (k>0) {
if ($k==1) {
ones++;
}
if (ones>=3) {
e[i]=1;
}
}
}
}
}
}
}
END{for (i in e) count++;print count}
Then run:
Code:
echo $string | awk -vFS="" -f script.awk
BTW, your script is giving "6" for this sample input...
Last edited by bartus11; 05-14-2012 at 04:13 PM..
Reason: fixed for first three characters
I am doing some training for a job I have just got and there is an exercise I am stuck with. I am not posting to ask a question about logic, just a trivial help with string manipulation. I would appreciate if somebody could at least give me a hint on how to do it.
Basically, the intelligent part... (8 Replies)
First of all I am VERY new to this so bare with me and try and explain everything even if it seems simple.
Basically I want to read a line of text from a html file. See if the line of text has a certain string in it. copy an unknown number of characters (the last 4 characters wiil be ".jpg" the... (1 Reply)
Hi!
I have some sequencing data that I have aligned using maq software
Now, I have data that looks like this each line is a 'tag'
chr1 10001
chr1 10002
chr1 10005
chr1 10007
chr1 10008
chr1 10008
chr1 10008
chr1 10019
chr1 10019
chr1 10020
What I really want to find out is how... (1 Reply)
Very simple problem I am not able to solve. I have been trying to modify the following code:
awk '{t=$1; c = x}{for (i = 1; i <= length; i += wn)print t FS"" substr($2, i, mx) > ("block" ++c)}' mx=100 wn=100 infile.txt
What I am tryng to acccomplish, I have a bunch of files where the first... (3 Replies)
I want to do the next
"I don't want to go school
because I'm sick today."
I want to join these two line but only when the first line is not more than 20 characters
and ended whit nothing or a comma and the second line not more than 15.
The 20 and the 15 can be change in the script.
I know... (10 Replies)
Hello
Could you help with small script:
How to split string X1 into 3 string
String X1 can have 1 or many strings
X1='A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3'
This is output which I want to have:
Z1='A1:B1:C1:D1'
Z2='A2:B2:C2:D2'
Z3='A3:B3:C3:D3' (5 Replies)
I'm doing a little work that involves computing the average completion time of the last 5 of many file decompressions. It's not too tough, but I'm wondering if maybe there's a better way to write it. This is a bash script; here's the current idea:
ctime5=$ctime4
ctime4=$ctime3
ctime3=$ctime2... (2 Replies)
i have something like this...
echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }'
Certifica
the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it.
expected output is
Certificate (7 Replies)
Hi Unix Gurus,
I have a file with data like:
>header_1
TCCCCGA
>header_2
CCAATTGGGTA
The data to work with starts from the next line after '>header_xx'.
(1)
I want to search the three letter patterns 'CHH' or 'DDG' and replace C and G by exclamation ! so that CHH becomes !HH and DDG... (3 Replies)
Discussion started by: Fahmida
3 Replies
LEARN ABOUT OSX
tswtclmt
tswtclmt(7ipp) IP Quality of Service Modules tswtclmt(7ipp)NAME
tswtclmt - Time Sliding Window Three Conformance Level Meter
DESCRIPTION
The Time Sliding Window Three Conformance level meter (tswtcl) meters a traffic stream and determines the conformance level of its packets.
Packets are deemed to belong to one of the three levels, Red, Yellow or Green, depending on the committed and peak rate.
The meter provides an estimate of the running average bandwidth. It takes into account burstiness and smoothes out its estimate to approx-
imate the longer-term measured sending rate of the traffic stream.
The estimated bandwidth approximates the running average bandwidth of the traffic stream over a specific window (time interval). tswtcl
estimates the average bandwidth using a time-based estimator. When a packet arrives for a class, tswtcl re-computes the average rate by
using the rate in the last window (time interval) and the size of the arriving packet. The window is then slid to start at the current time
(the packet arrival time). If the computed rate is less than the committed configuration parameter, the packet is deemed Green; else if the
rate is less than the peak rate, it is Yellow; else Red. To avoid dropping multiple packets within a TCP window, tswtcl probabilistically
assigns one of the three conformance level to the packet.
STATISTICS
The tswtcl module exports global and per-class statistics through kstat:
Global statistics:
module: tswtclmt instance: <action id>
name: tswtclmt statistics class <action name>
green_bits <number of bit in green>
green_packets <number of packets in green>
red_bits <number of bits in red>
red_packets <number of packets in red>
yellow_bits <number of bits in yellow>
yellow_packets <number of packets in yellow>
FILES
/kernel/ipp/sparcv9/tswtclmt
64-bit module (SPARC only.)
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWqos |
+-----------------------------+-----------------------------+
SEE ALSO ipqosconf(1M), dlcosmk(7IPP), dscpmk(7IPP), flowacct(7IPP), ipqos(7IPP), ipgpc(7IPP), tokenmt(7IPP)
RFC 2859, A Time Sliding Window Three Colour Marker (TSWTCM) W. Fang, N. Seddigh, B. Nandy -- The Internet Society, 2000
SunOS 5.10 29 Sep 2004 tswtclmt(7ipp)