I've a lot of ascii files that I would like to reformat :
One of files's column (for exemple $5) contains increasing numbers (see exemple) :
$5=
[...]
What I'd like to do is to assign the value "1" for the first record of a consistant block ( a block is defined by the same $5 number), "2" for middle records and "3" for the last one. Then another "1" for the next block, etc. :
In my exemple, the file may become :
$5=
[...]
I've tested some stuff with awk but I always failed...
If you've got some ideas to help me... you're welcome.
Nico.
ps : Please excuse my poor English, I'm from France
---------- Post updated at 04:23 PM ---------- Previous update was at 04:04 PM ----------
I've tryed this...
but it does not work :/
Last edited by radoulov; 11-12-2009 at 03:45 AM..
Reason: added code tags
Consecutive default FS characters will be squeezed because of the ricompilation of the record,
let me know if this could be a problem.
With no default FS an OFS should be explicitly specified.
I've tested my ancient script in an Exceed emulated unix... It also works... (whereas it doesn't works on cygwin...) But your solution keeps all the others columns. It's perfect for me.
For the moment I don't understand all the syntax of your script... but I'll try to study a little bit the problem. =)
Hi All,
I have an ascii file in which few columns are having hex values which i need to convert into ascii. Kindly suggest me what command can be used in unix shell scripting?
Thanks in Advance (2 Replies)
Hi All,
I am trying to remove (SELECTIVE - passed as argument) Extended ASCII using Awk based on adhoc basis. Can you please let me know how to do it. I have to implement this using awk only.
Thanks & Regads (14 Replies)
Hi i have a unix date in file a file like this '1313675999'
in oracle i would do it like this
select TO_CHAR ( TO_DATE ('01011970', 'DDMMYYYY')+ 1 / 24 / 60 / 60 * 1313675999,'YYYYMMDD') from dual how to achive the same in unix ? (8 Replies)
I have a bif text file with the following format:
d1_03 fr:23
d1_03 fr:56
d1_03 fr:67
d1_03 fr:78
d1_01 fr:35
d1_01 fr:29
d1_01 fr:45
d2_09 fr:34
d2_09 fr:78
d3_98 fr:90
d3_98 fr:104
d3_98 fr:360
I have like thousands of such lines
I want to reformat this file based on column 1... (3 Replies)
I have a set of free-form phone numbers that are not uniform and I want to reformat them into a standard uniform string. These are embedded at the end of a colon seperated file built by a large nawk + tr piping like such:
XXXXX:YYYYY:ZZZZZ:(333)333-3333x33333
XXXXX:YYYYY:ZZZZZ:x44444... (9 Replies)
Hi gurus,
I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Dear users,
I am new to AWK and have been battling with this one for close to a week now. Some of you did offer some help last week but I think I may not have explained myself very well. So I am trying again.
I have a dataset that has the following format where the datasets repeat every... (5 Replies)
looking to do the following...
What the data looks like
server1 02/01/2008 groups 10
server1 03/01/2008 groups 15
server1 04/01/2008 groups 20
server2 02/01/2008 users 50
server2 03/01/2008 users 75
server2 04/01/2008 users 100
server2 04/01/2008 users 125
What I would like the... (1 Reply)
Hello, I am having a trouble with awk attempting to reformat a two columns file , such as below:
201 84
201 370
201 544
201 600
213 99
213 250
213 431
220 65
220 129
220 338
220 408
220 501
220 550
231 101
231 350
What I need to do is is to add a third column containing a... (4 Replies)