Sponsored Content
Top Forums Shell Programming and Scripting Help with ... Formating the file using awk Post 303018088 by manas_ranjan on Tuesday 29th of May 2018 08:30:58 AM
Old 05-29-2018
thanks, it was typo that no position2 with a "-" in field 6 ..let me try it out first and next time I will take care of it.

---------- Post updated at 07:30 AM ---------- Previous update was at 02:58 AM ----------

I have tried to change the below format o/p to something like

Code:
awk -F"[ :\t]+" 'NF {A[$1,$6]++}END{for(i in A)print i,A[i]}' OFS=, SUBSEP=, file4
position3,-,1
position3,client5,2
position2,client4,2
position2,client3,1
position1,client2,1
position1,client1,3

this

Code:
positiondetails,position=position3,client=- <space> count=1
positiondetails,position=position3,client=client5<space> count=2
positiondetails,position=position2,client=client4<space> count=2
positiondetails,position=position2,client=client3<space> count=1
positiondetails,position=position1,client=client2<space> count=1
positiondetails,position=position1,client=client1<space> count=3

Code:
awk -F"[ :\t]+" 'NF {A[$1,$6]++}END{for(i in A){count=A[i]; split(i, w, ",") ; for (j in w) printf("positiondetails,position=%s count=%d", w[j], count}}' OFS=, SUBSEP=, file4

this prints everything one after another, but this is not what I would like to print, can anyone guide me thru? I hope this makes sense.

Last edited by manas_ranjan; 05-29-2018 at 05:06 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help required on file formating

I have two files file1 and file2 as shown below: file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 (1 Reply)
Discussion started by: udiptya
1 Replies

2. Shell Programming and Scripting

AWK: formating number without printf

Hello, I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value immediately). Schematically here is what I have: awk 'BEGIN{number=0.01234567} $1==$2{$3=number}... (5 Replies)
Discussion started by: jolecanard
5 Replies

3. Shell Programming and Scripting

file formating in Perl

Hi, I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement .. My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Discussion started by: julirani
1 Replies

4. UNIX for Dummies Questions & Answers

File formating help needed.

I have a file called vm.cfg . content of file. acpi = 1 apic = 1 builder = 'hvm' How would i write a script which will add boot = 'd' at 3rd line. For example. after running the script the file should be like below. acpi = 1 apic = 1 boot = 'd' builder = 'hvm' I dont want to... (3 Replies)
Discussion started by: pinga123
3 Replies

5. Shell Programming and Scripting

Help in formating a txt file

Pls help in formatting a txt file using shell scripting Input file format: Name priya 2010-09-21 10:43:49 TEXT ID 1 hi TEXT ID 2 how TEXT ID 3 r TEXT ID 4 u Output required: name priya hi how r u (4 Replies)
Discussion started by: bha148
4 Replies

6. Shell Programming and Scripting

formating sql file using awk or sed

Hi, I have a file where I would like to add a prompt type object_name statement before every create commnad create or replace force view test_view_01 ( col1 col2 col3 ) as (select a,b,c from sometable ); create or replace view test_view_02 ( col4 col5 col6 ) as (5 Replies)
Discussion started by: jville
5 Replies

7. UNIX for Beginners Questions & Answers

File formating with lines

Hi All, Need to modify a file basically join the extra line to one I am having a file like below And would like to make it as below . (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

8. UNIX for Beginners Questions & Answers

File formating help

Hi all, I am having the file below I need that as below Thanks, Arun (12 Replies)
Discussion started by: arunkumar_mca
12 Replies

9. Shell Programming and Scripting

File formating

I need to create a fixed width file based on the column lengths. lets assume I have six(this may be dynamic) fields each are of different length column1=6 #size of the column column2=3 column3=2 column4=3 column5=4 column6=5 I tried below code snippet but it is not working echo... (4 Replies)
Discussion started by: gvkumar25
4 Replies

10. UNIX for Beginners Questions & Answers

awk HTML Conditional Formating

I am receiving the below output in text format. The output is converted to HTML table using the code mentioned below output in text LogDate DayOfWeek/Hours _0_ _1_ _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ _10_ _11_ _12_ _13_ _14_ _15_ _16_ ... (3 Replies)
Discussion started by: Dumpi16
3 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_buffer_write_at, ldns_buffer_write_at, ldns_buffer_write, ldns_buffer_write_string_at, ldns_buffer_write_string, ldns_buf- fer_write_u8_at, ldns_buffer_write_u8, ldns_buffer_write_u16_at, ldns_buffer_write_u16, ldns_buffer_read_at, ldns_buffer_read, ldns_buf- fer_read_u8_at, ldns_buffer_read_u8, ldns_buffer_read_u16_at, ldns_buffer_read_u16, ldns_buffer_read_u32_at, ldns_buffer_read_u32- SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> void ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t count); void ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t count); void ldns_buffer_write(ldns_buffer *buffer, const void *data, size_t count); void ldns_buffer_write_string_at(ldns_buffer *buffer, size_t at, const char *str); void ldns_buffer_write_string(ldns_buffer *buffer, const char *str); void ldns_buffer_write_u8_at(ldns_buffer *buffer, size_t at, uint8_t data); void ldns_buffer_write_u8(ldns_buffer *buffer, uint8_t data); void ldns_buffer_write_u16_at(ldns_buffer *buffer, size_t at, uint16_t data); void ldns_buffer_write_u16(ldns_buffer *buffer, uint16_t data); void ldns_buffer_read_at(ldns_buffer *buffer, size_t at, void *data, size_t count); void ldns_buffer_read(ldns_buffer *buffer, void *data, size_t count); uint8_t ldns_buffer_read_u8_at(ldns_buffer *buffer, size_t at); uint8_t ldns_buffer_read_u8(ldns_buffer *buffer); uint16_t ldns_buffer_read_u16_at(ldns_buffer *buffer, size_t at); uint16_t ldns_buffer_read_u16(ldns_buffer *buffer); uint32_t ldns_buffer_read_u32_at(ldns_buffer *buffer, size_t at); uint32_t ldns_buffer_read_u32(ldns_buffer *buffer); DESCRIPTION
ldns_buffer_write_at() writes the given data to the buffer at the specified position buffer: the buffer at: the position (in number of bytes) to write the data at data: pointer to the data to write to the buffer count: the number of bytes of data to write ldns_buffer_write_at() writes the given data to the buffer at the specified position buffer: the buffer at: the position (in number of bytes) to write the data at data: pointer to the data to write to the buffer count: the number of bytes of data to write ldns_buffer_write() writes count bytes of data to the current position of the buffer buffer: the buffer data: the data to write count: the lenght of the data to write ldns_buffer_write_string_at() copies the given (null-delimited) string to the specified position at the buffer buffer: the buffer at: the position in the buffer str: the string to write ldns_buffer_write_string() copies the given (null-delimited) string to the current position at the buffer buffer: the buffer str: the string to write ldns_buffer_write_u8_at() writes the given byte of data at the given position in the buffer buffer: the buffer at: the position in the buffer data: the 8 bits to write ldns_buffer_write_u8() writes the given byte of data at the current position in the buffer buffer: the buffer data: the 8 bits to write ldns_buffer_write_u16_at() writes the given 2 byte integer at the given position in the buffer buffer: the buffer at: the position in the buffer data: the 16 bits to write ldns_buffer_write_u16() writes the given 2 byte integer at the current position in the buffer buffer: the buffer data: the 16 bits to write ldns_buffer_read_at() copies count bytes of data at the given position to the given data-array buffer: the buffer at: the position in the buffer to start data: buffer to copy to count: the length of the data to copy ldns_buffer_read() copies count bytes of data at the current position to the given data-array buffer: the buffer data: buffer to copy to count: the length of the data to copy ldns_buffer_read_u8_at() returns the byte value at the given position in the buffer buffer: the buffer at: the position in the buffer Returns 1 byte integer ldns_buffer_read_u8() returns the byte value at the current position in the buffer buffer: the buffer Returns 1 byte integer ldns_buffer_read_u16_at() returns the 2-byte integer value at the given position in the buffer buffer: the buffer at: position in the buffer Returns 2 byte integer ldns_buffer_read_u16() returns the 2-byte integer value at the current position in the buffer buffer: the buffer Returns 2 byte integer ldns_buffer_read_u32_at() returns the 4-byte integer value at the given position in the buffer buffer: the buffer at: position in the buffer Returns 4 byte integer ldns_buffer_read_u32() returns the 4-byte integer value at the current position in the buffer buffer: the buffer Returns 4 byte integer AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_buffer. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 06:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy