Something like this?
noise and data are arbitrary file names
--
if you are using gawk, use gawk --posix
This wil not work with mawk
On Solaris use /usr/xpg4/bin/awk
I do not believe that this solution is correct. This approach depends on whitespace between fields. In the sample data, there are instances where there is no whitespace. This suggests that the data format consists of fixed-width records with fixed width fields. Further, there are some records that do not contain any station names at all.
The format looks like 6 characters for the station immediately followed by 6 characters for the time. If the time is less than 6 characters, it is right-justified and space padded. 6 pairs of station-time per record for a total of 72 characters per record.
Perhaps the OP could elaborate on the data format. Along with my assumptions above, responses to the following questions would be helpful: Do all station fields contain at least one letter? If so, should station fields with a numeric value, along with the paired time field, be skipped?
By the way, Scrutinizer, why the qualifications for gawk and mawk? Something about the sub() regular expression?
mawk and gawk (without --posix or --re-interval) do not support interval expressions..
Perhaps run it through sed 's/....../& /g' first..
My first thought was to just use fold, pipe into awk to do the math, then paste. But it seems that some lines aren't 72 characters long. Specifically, when a station field doesn't contain a letter, it signals a series of numeric values that may not necessarily end on the 72nd character of a line.
Regarding gawk and interval expressions, I was bitten hard by that in the late 90s. Nearly 15 years later, I still vividly recall what the code was supposed to accomplish, the details of the hardware, the hum of the machines in the room, what was hanging on the walls, the scent of the air freshener, and that after what seemed a frustrating eternity, I stumbled across the --re-interval option. Fortunately, it's no longer the case.
Interval expressions were not traditionally available in awk. They were added as part of the POSIX standard to make awk and egrep consistent with each other.
Initially, because old programs may use ‘{’ and ‘}’ in regexp constants, gawk did not match interval expressions in regexps.
However, beginning with version 4.0, gawk does match interval expressions by default. This is because compatibility with POSIX has become more important to most gawk users than compatibility with old programs.
Yes there header lines between eveeeery record. Which are starting with date:
This line contains 48 characters.
And the station information is 6 characters also the time information is 6 characters again. This data is an output of f code so the spaces are pre-defined in the code for the station name and the time.
There also lines with
In the first line zeros help the line to be finish till the 72nd character. So the number of the zeros after the last time information is not fixed it depends on the number of the stations recorded for an event.
The second line is a mark between the events. a full line with zeros till the 72 nd character.
Except the full zero lines and header lines all the lines contain station names. A station name can be 4 or 3 character after that information there is another information like P0, S0..... So if the station name is 3 character is becomes :
Thanks everyone helping me...
Heey it works perfectly and could you please explain the code a little bit it is really compilicated for me to understand
And Again thank you everyone who tryed to help
---------- Post updated at 09:10 AM ---------- Previous update was at 04:09 AM ----------
Quote:
Originally Posted by raj_saini20
Try this (tested in hp-ux)
and output is
I am so sory but we needed to change the format of the input file a little bit I tried to modify your code but could not write full station names
here is the input
Only there are,this time, the spaces between station information and the time information increased and there are only 2 digits for the time information the rest is the same
I will be very happy if you tell me how can I use this input for the same process...
Hello,
I have a shell script through which I am executing .sql file and spooling the result of Query from .sql . I want to spool the result in ascending order. Is there any parameter to be set to print result in ascending or descending order.
Thanks in advance. (4 Replies)
is it possible to order the following row clusters from ascending to descending. thanx in advance
input
1 2 4 0
1 2 4 0
3 3 3 3
1 5 1 0
1 5 1 0
6 0 0 0
5 1 1 1... (4 Replies)
Hi folks
I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file.
It all works - apart from the xml and config file format in the new file
with XML files the original XML (that ends up in... (2 Replies)
Hi experts,
I have a list of files containing forces as the only number as follows.
Force1.txt Force2.txt Force3.txt Force4.txt Force5.txt . . . . . . . . . Force100.txt I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 .... (2 Replies)
I want to generate an awk function that generated a Gaussian distributed set of random numbers. I need to implement the thing below in awk. Rnd is just a uniform random number between 0 and 1
function rgaussian(r1, r2) {
Do
v1 = 2 * Rnd - 1
v2 = 2 * Rnd - 1
... (0 Replies)
Hi guys, I'm having some difficulties in insert some details to the following contents.
I need to insert "TEST" under MIR & a value "25" to the next line.
So far, I am able to insert "TEST" by using awk to capture MIR as the identifier.
However, I am having some difficulties in inserting "25"... (3 Replies)
Hi
I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example.
The original data record should be some thing like this
60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Hi All,
I enhanced a perl script that creates a table with xyz_yyyymm and insert data from xyz table before truncate xyz.I have tested it successfully in dev but when i ran it on production new table xyz_yyyymm created but did not insert any records from xyz.(No errors were thrown)The perl... (1 Reply)
I'm hoping someone can help me on this. I have a data file that greatly simplified might look like this:
sec;src;dst;proto
421;10.10.10.1;10.10.10.2;tcp
426;10.10.10.3;10.10.10.4;udp
442;10.10.10.5;10.10.10.6;tcp
sec;src;fac;dst;proto
521;10.10.10.1;ab;10.10.10.2;tcp... (3 Replies)