Search log file for entry range between 2 epoch times - perl

I'm using awk to search a log file for a list of lines that fell between two epoch times.
This is what I've done... (I'm getting a massive list of entries)
awk '/([1480360000..1480380000])/' /Location/Data.txt
I'm also wanting to be able to replace the times with Perl Variables without having to use [0-9][0-9]and use it within a perl script. I'm puzzled.
system(awk '/([$MinRange..$MaxRange])/' /Location/Data.txt)
Thanks

This is just to give an answer based on ooags comment.
To search from a number to a number:
cat file
1 one
2 two
3 thee
4 four
5 five
6 six
7 seven
8 eight
9 nine
10 ten
awk '$1>=4 && $1<=8' file
4 four
5 five
6 six
7 seven
8 eight
Bracket are used to get from to within single letter or single number.
[a-z] from a to z
[5-8] from 5 to 8
[0-9][0-9][0-9] from 000 to 999
([0-9]|[1-9][0-9]|[1-9][0-9][0-9]) this would give from 0 to 999
etc

Related

How to take input in python

Input format
1.The first line contains T,the number of test cases
2. The following T lines contains a number n
Example:
5
1
7
10
300
55
I am new to this language i Know the simple inputs but I couldn't understand this multiple input pattern

How can I calculate the average between two text files based on matrixes?

I am fairly new to using MATLAB. I have two text files that have 500 rows x 100 columns and every one of it has a random value.
For example:
1 2 3 4 5
6 7 8 9 2
4 5 6 6 8
So my question is, corresponding to the row and column, how can I calculate the average of each particular field corresponding to the row and column?
For instance, at (1,1) in text1.txt is 20 and at (1,1) in text2.txt is 40. The average is 30 and I want to display this result in an another file at (1,1).
Many thanks.
assuming the files are named 'a' and 'b':
load a
load b
c=(a+b)/2;
save('c','c','-ascii');

Sorting different numbers into equal stacks

Hello I'm sort of new to matlab but I am working on a program that will take a bunch of numbers (prices) and sort them into groups that have near the same or near equivalent value (equal cost). However I'm not sure how to program that... does this already exist? If not how should I go about sorting these items.
Ex. sort 3 4 4 4 5 6 7 into 4 piles. 33/4 = 8.25 = Avg
Piles are 7 (4+4) (3+6) (4+5) or 7 8 9 9
Obviously these would also have two decimal places behind them (3.XX) any ideas?

MATLAB/OCTAVE - Branching loops? or parallel looping?

Still new to the programing game but I need a little help! I'm not exactly sure how to describe what I want to do but I'll give it my best shot. I have a set of numbers produced by an algorithm I've put together. e.g. :
....
10 10 10
11 11 11
12 1 2
13 3 4
14 12 13
15 6 7
16 5 15
17 8 9
....
Essentially what I want to do is assign these index numbers to groups. Lets say I start with the number 14 in the first column. It is going to belong to group 1, so I label it in a new column in row 14 "1" for group one. The second and the third column show other index numbers that are grouped with the index 14. So I use a code like:
FindLHS = find(matrix(:,1)==matrix(14,2));
and
FindRHS = find(matrix(:,1)==matrix(14,3));
so clearly this will produce the results of
FindLHS = 12
FindRHS = 13
I will then proceed to label both 12 and 13 as belonging to group "1" as I did for 14
now my problem is I want to do this same procedure for both 12 and 13 of finding and labelling the indexs for 12 and 13 being (1,2) and (3,4). Is there a way to repeat that code for both idx of 1,2,3 and 4? because the real dataset has over 5000 data points in it...
Do you understand what I mean?
Thanks
James
All you really want to do is find wherever matrix(:,1) contains one of the numbers you've already found, include the numbers in the second and third columns into your group list (presuming they aren't already there), and stop when that list stops growing, right? This may not be the most efficient way of doing it but it gives you the basic idea:
while ~(numel(oldnum)==numel(num))
oldnum = num;
idx = ismember(matrix(:,1),oldnum)
num = unique(matrix(idx,:))
end
Output:
num =
1
2
3
4
12
13
14
Now if your first column is literally just your numbers 1 through 5000 in order, you don't need to even find the index, you can just use your number list directly.
To do this for multiple groups you would just need an outer loop that stores the information for each group, then picks out the next unused number. I'm presuming that your individual groups are consistent so that no matter which of those numbers you pick you end up with the same result - e.g. starting at 2 or 14 gives you the same result (if not, it becomes more complex).

How to find out if numbers are different in pascal?

i can't solve one pascal problem, first i have to enter N which is the number or mesurments, next i enter those mesurments (if N is 5 i enter 5 mesurments for exmaple 3 4 5 6 7). After that i enter Q which is the number of times i check the number of different numbers in a specific part of the row. For example you have input
5 (number of mesurments)
1 2 3 3 4 (mesurments)
3 (number of checkings)
1 3
3 4
1 5 (left number is the starting number from the row, if it's 1 you start from 1, if it's 4 you start from 3 because 3 is the fourth mesurment and the right number is the last number if it's 5 it would be 4 because 4 is the fifth in the row)
And for output you would get
3
1
4 (for the first checking you have number from 1 to 3 (1 2 3) and you have 3 different numbers, second mesurment from 3 to 4 (3 3) and it's 1 different number and last from 1 to 5 there are 4 different numbers)
Hope you understod me, and thanks if you can solve it, i am in highschool now and i am preparing my self for something more complicating :) thanks in advance
The inequality operator of Pascal is <>