Sponsored Content
Top Forums Shell Programming and Scripting Adding new fields to an existing layout Post 302361822 by Amit.Sagpariya on Wednesday 14th of October 2009 07:22:18 AM
Old 10-14-2009
Here is code :
Code:
#! /bin/ksh

aa=" "
cnt=`wc -l a.txt | awk '{print $1}'`
num=`expr $cnt - 1 | bc`
head -$num a.txt >> new.txt
let i=1

let sec=`tail -1 new.txt | awk '{print $2}'`
las=`tail -1 new.txt | awk '{print $4}'`
let llas=`echo $las | awk -F, '{print $1}'`


bcnt=`wc -l b.txt | awk '{print $1}'`

while [ $i -le $bcnt ]
do
	col1=`head -$i b.txt| tail -1 | awk '{print $1}'`
	col2=`expr $sec + $llas | bc`
	col3=`head -$i b.txt | tail -1 | awk '{print $2}'`
	col4=`head -$i b.txt | tail -1 | awk '{print $3}'`
	echo "${col1}${aa}${col2}${aa}${col3}${aa}${col4}" >> new.txt
	let i=`expr $i + 1 | bc`
	let sec=$col2
	let llas=`echo $col4 | awk -F, '{print $1}'`
	
done
tail -1 a.txt >> new.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Create a calculated field from existing fields

I need to add an average field to a file. I can create it in an on-screen report and it does what I need using the awk command but I can't get it to create a new file with the additional field. Here's what I'm working with: file layout: id:lastname:firstname:grade1:grade2:grade3:grade4 I... (1 Reply)
Discussion started by: atchleykl
1 Replies

2. Solaris

SMF - Adding instances to existing manifest

I have a default, sun supplied, apache2 install on solaris10. It's running fine, everything's great. I'm looking to add another instance, fairly happy with how to do that apart from one thing - the SMF manifest. Can i just edit the XML file sun supplied for the default apache2 and add in details... (2 Replies)
Discussion started by: craigp84
2 Replies

3. UNIX for Dummies Questions & Answers

Adding header to an existing file

Dear All, I need to add a header of one line to an already existing file. I know that it can be achieved by the following: echo "Header" > newfile cat file1 >> newfile But my problem is that file is huge and there is no space for creating a new file every time. Is there a way that I can... (5 Replies)
Discussion started by: shash
5 Replies

4. Linux

Adding space to existing mount

I am on Red Hat Linux 4.7. I am getting this error message: Preparing... ########################################### You have insufficient diskspace in the destination directory (/usr/lib) to install xxxxxxxxxxxxx. The installation requires at least 1.5 GB free on this... (2 Replies)
Discussion started by: jxh461
2 Replies

5. Shell Programming and Scripting

Adding file to an existing tar

Hi Friends, I want to know the command to add a new file in a existing tar file. For Ex: I have a tar file file1.tar with the contents one.txt two.txt three.txt Now I need to add file four.txt to this existing tar file, how can I do it? Thanks in advance (4 Replies)
Discussion started by: mr_manii
4 Replies

6. Web Development

Adding a Web Calendar to an existing Groupware

Hi All, I have an existing groupware consisting of postfix,dovecot,openldap and webmail(RoundCube). But It lacks a shared calendar. Can someone advise how can I implement a calendar in my groupware ? Thanks. (1 Reply)
Discussion started by: coolatt
1 Replies

7. Shell Programming and Scripting

Adding New Selections to the existing Script

Hi.... i have two scripts called: "type" & "selecttype". In "type" i have only the name of the products ex.: product1 & product2. Now, i have to ADD product3 which includes sub categories: productA, productB, productC, productD, productE, productF. so my New type script (menu) looks as... (1 Reply)
Discussion started by: Netrock
1 Replies

8. Shell Programming and Scripting

Adding existing set of records in the same file

I have a file with 50,000 records in it, i have a requirement to use the same 50,000 records and add them 4 times to the same file to make a total of 200,000 records. I was wondering how to do this using ksh. Any help is greatly appreciated. (2 Replies)
Discussion started by: vpv0002
2 Replies

9. AIX

Adding existing VG to powerHA Resource group

Hello. I am Running AIX 6.1 and PowerHA 6.1 I have an active/active cluster (Prod/Dev) cluster. Each side will failover to the other. I have on my prod side an active volume group with a file system. The VG is imported on both nodes and active (varried on, file system mounted) on the prod... (3 Replies)
Discussion started by: mhenryj
3 Replies

10. Shell Programming and Scripting

Adding a new column to an existing one

I have a data file that looks like this: 0.01 1 3822 4.97379915032e-14 4.96982253992e-09 0 0.01 3822 1 4.97379915032e-14 4.96982253992e-09 0 0.01 2 502 0.00993165137406 993.165137406 0 0.01 502 2 0.00993165137406 993.165137406 0 0.01 4 33 0.00189645523539 189.645523539 0 0.01 33 4... (3 Replies)
Discussion started by: kayak
3 Replies
layout.h(3)							       log4c							       layout.h(3)

NAME
layout.h - Interface for user specific layout format of log4c_logging_event events. SYNOPSIS
#include <log4c/defs.h> #include <log4c/logging_event.h> #include <stdio.h> Data Structures struct log4c_layout_type log4c layout type class Defines #define log4c_layout_type_define(a_type) Typedefs typedef struct __log4c_layout log4c_layout_t typedef struct log4c_layout_type log4c_layout_type_t log4c layout type class Functions LOG4C_API const log4c_layout_type_t * log4c_layout_type_get (const char *a_name) LOG4C_API const log4c_layout_type_t * log4c_layout_type_set (const log4c_layout_type_t *a_type) LOG4C_API log4c_layout_t * log4c_layout_get (const char *a_name) LOG4C_API log4c_layout_t * log4c_layout_new (const char *a_name) LOG4C_API void log4c_layout_delete (log4c_layout_t *a_layout) LOG4C_API const char * log4c_layout_get_name (const log4c_layout_t *a_layout) LOG4C_API const log4c_layout_type_t * log4c_layout_get_type (const log4c_layout_t *a_layout) LOG4C_API const log4c_layout_type_t * log4c_layout_set_type (log4c_layout_t *a_layout, const log4c_layout_type_t *a_type) LOG4C_API void * log4c_layout_get_udata (const log4c_layout_t *a_layout) LOG4C_API void * log4c_layout_set_udata (log4c_layout_t *a_layout, void *a_udata) LOG4C_API const char * log4c_layout_format (const log4c_layout_t *a_layout, const log4c_logging_event_t *a_event) LOG4C_API void log4c_layout_print (const log4c_layout_t *a_layout, FILE *a_stream) LOG4C_API void log4c_layout_types_print (FILE *fp) Detailed Description Interface for user specific layout format of log4c_logging_event events. Todo the layout interface needs a better configuration system depending on the layout type. The udata field is a just a trick. Todo a pattern layout would be welcomed !! Define Documentation #define log4c_layout_type_define(a_type) Helper macro to define static layout types. Parameters: a_type the log4c_layout_type_t object to define Warning: needs GCC support: otherwise this macro does nothing Deprecated This macro, and the static initialialization of layouts in general, is deprecated. Use rather the log4c_layout_type_set() function to initialize your appenders before calling log4c_init() Typedef Documentation typedef struct __log4c_layout log4c_layout_t log4c layout class typedef struct log4c_layout_type log4c_layout_type_t log4c layout type class Attributes description: o name layout type name o format Function Documentation LOG4C_API void log4c_layout_delete (log4c_layout_t *a_layout) Destructor for layout. LOG4C_API const char* log4c_layout_format (const log4c_layout_t *a_layout, const log4c_logging_event_t *a_event) format a log4c_logging_event events to a string. Parameters: a_layout the log4c_layout_t object a_event a logging_event_t object Returns: an appendable string. LOG4C_API log4c_layout_t* log4c_layout_get (const char *a_name) Get a pointer to an existing layout. Parameters: a_name the name of the layout to return. Returns: a pointer to an existing layout, or NULL if no layout with the specfied name exists. LOG4C_API const char* log4c_layout_get_name (const log4c_layout_t *a_layout) Parameters: a_layout the log4c_layout_t object Returns: the layout name LOG4C_API const log4c_layout_type_t* log4c_layout_get_type (const log4c_layout_t *a_layout) Parameters: a_layout the log4c_layout_t object Returns: a log4c_layout_type_t object LOG4C_API void* log4c_layout_get_udata (const log4c_layout_t *a_layout) Parameters: a_layout the log4c_layout_t object Returns: the layout user data LOG4C_API log4c_layout_t* log4c_layout_new (const char *a_name) Constructor for layout. LOG4C_API void log4c_layout_print (const log4c_layout_t *a_layout, FILE *a_stream) prints the layout on a stream Parameters: a_layout the log4c_layout_t object a_stream the stream LOG4C_API const log4c_layout_type_t* log4c_layout_set_type (log4c_layout_t *a_layout, const log4c_layout_type_t *a_type) sets the layout type Parameters: a_layout the log4c_layout_t object a_type the new layout type Returns: the previous layout type LOG4C_API void* log4c_layout_set_udata (log4c_layout_t *a_layout, void *a_udata) sets the layout user data Parameters: a_layout the log4c_layout_t object a_udata the new layout user data Returns: the previous layout user data LOG4C_API const log4c_layout_type_t* log4c_layout_type_get (const char *a_name) Get a pointer to an existing layout type. Parameters: a_name the name of the layout type to return. Returns: a pointer to an existing layout type, or NULL if no layout type with the specified name exists. LOG4C_API const log4c_layout_type_t* log4c_layout_type_set (const log4c_layout_type_t *a_type) Use this function to register a layout type with log4c. Once this is done you may refer to this type by name both programatically and in the log4c configuration file. Parameters: a_type a pointer to the new layout type to set. Returns: a pointer to the previous layout type of same name. Example code fragment: const log4c_layout_type_t log4c_layout_type_xml = { 's13_xml', xml_format, }; log4c_layout_type_set(&log4c_layout_type_xml); LOG4C_API void log4c_layout_types_print (FILE *fp) prints all the current registered layout types on a stream Parameters: fp the stream Author Generated automatically by Doxygen for log4c from the source code. Version 1.2.1 Mon May 2 2011 layout.h(3)
All times are GMT -4. The time now is 11:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy