Sponsored Content
Top Forums Shell Programming and Scripting Fill the Key fields : Please help us Post 302180384 by Klashxx on Monday 31st of March 2008 02:30:05 AM
Old 03-31-2008
Code:
>cat file
E100,0,5/29/1993,0,E001,E000,A,500000,41666.667,240.384615
0,1/23/1994,0,E001,E003,A,125400,10450,60.288462
0,6/4/1994,0,E001,E003,A,95000,7916.667,45.673077
E101,0,7/30/1993,0,E001,E003,A,87000,7250,41.826923
1/9/1993,0,E001,E003,A,45200,3766.667,21.730769
E103,0,2/3/1995,0,E001,E003,A,15000,1250,7.211538
E104,0,2/15/1995,0,E001,E001,A,78000,6500,37.5

Code:
>awk 'NF!=10{for(i=1;i<=(10-NF);i++)printf("%s,",k[i]);print;next}{for(i=1;i<=3;i++)k[i]=$i}1' FS=',' f1
E100,0,5/29/1993,0,E001,E000,A,500000,41666.667,240.384615
E100,0,1/23/1994,0,E001,E003,A,125400,10450,60.288462
E100,0,6/4/1994,0,E001,E003,A,95000,7916.667,45.673077
E101,0,7/30/1993,0,E001,E003,A,87000,7250,41.826923
E101,0,1/9/1993,0,E001,E003,A,45200,3766.667,21.730769
E103,0,2/3/1995,0,E001,E003,A,15000,1250,7.211538
E104,0,2/15/1995,0,E001,E001,A,78000,6500,37.5

 

9 More Discussions You Might Find Interesting

1. Solaris

Esc key/Auto-fill

I'm an HPUX/Linux guy, who appreciates occasionally hitting the Esc key for Auto-fill... Does sunOS have anything like this? This is my 1st post, and I didn't want to waste it :D thanks, manuel (3 Replies)
Discussion started by: mr_manny
3 Replies

2. Shell Programming and Scripting

align several fields and fill spaces with zero

hi all, i have a big problem, and i donīt know what to do. i have a flat file with several fields, which are separated by ";" like this: 5656838-7B;97030000-7;*;V16106133 ;1;1; 4612062-0B;97030000-7;*;C14038149 ;1;2; 8044938-0B;97030000-7;*;V16034219 ;1;2; where B is a blank space. ... (2 Replies)
Discussion started by: DebianJ
2 Replies

3. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

4. Shell Programming and Scripting

Matching by key fields

I have a file (key.dat) that contains two columns: AA|1234| BB|567| CC|8910| I have another file (extract.dat) that contains some data: SD|458|John|Smith| AA|3345|Frank|Williams| AA|1234|Bill|Garner| BD|0098|Yu|Lin| BB|567|Gail|Hansen| CC|8910|Ken|Nielsen| I want to compare the... (5 Replies)
Discussion started by: ChicagoBlues
5 Replies

5. Shell Programming and Scripting

Perl function to sort a file based on key fields

Hi, I am new to PERL.I want to sort all the lines in a file based on 1,2 and 4th filelds. Can U suggest me a command/function in perl for this operation.. (5 Replies)
Discussion started by: karthikd214
5 Replies

6. Shell Programming and Scripting

Compare Fields from two text files using key columns

Hi All, I have two files to compare. Each has 10 columns with first 4 columns being key index together. The rest of the columns have monetary values. Using Perl, I want to read one file into hash; check for the key value availability in file 2; then compare the values in the rest of 6... (2 Replies)
Discussion started by: Sangtha
2 Replies

7. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

8. UNIX for Dummies Questions & Answers

Fill fields with awk from an array?

Hi experts, I have been trying for a while to accomplish the following task using awk, and I just don't seem find find a way. I am not particular about using awk, it just seemed like the logical choice at first. I have a file that contains 5 fields that are delimited by a space character.... (1 Reply)
Discussion started by: GermanicGalore
1 Replies

9. Shell Programming and Scripting

Join and merge multiple files with duplicate key and fill void columns

Join and merge multiple files with duplicate key and fill void columns Hi guys, I have many files that I want to merge: file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: (5 Replies)
Discussion started by: yjacknewton
5 Replies
Alzabo::Create::ColumnDefinition(3pm)			User Contributed Perl Documentation		     Alzabo::Create::ColumnDefinition(3pm)

NAME
Alzabo::Create::ColumnDefinition - Column definition object for schema creation SYNOPSIS
use Alzabo::Create::ColumnDefinition; DESCRIPTION
This object holds information on a column that might need to be shared with another column. The reason this class exists is that if a col- umn is a key in two or more tables, then some of the information related to that column should change automatically in multiple places whenever it changes at all. Right now this is only type ('VARCHAR', 'NUMBER', etc) and length/precision information. This object also has an 'owner', which is the column which created it. INHERITS FROM
"Alzabo::ColumnDefinition" Note: all relevant documentation from the superclass has been merged into this document. METHODS
new This method takes the following parameters: * owner => "Alzabo::Create::ColumnDefinition" object * type => $type It returns a new "Alzabo::Create::ColumnDefinition" object. alter See the "Alzabo::Column->alter()" method for details. type Returns the object's type as a string. set_type ($string) Sets the object's type. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" length Returns the length attribute of the column, or undef if there is none. precision Returns the precision attribute of the column, or undef if there is none. set_length This method takes the following parameters: * length => $length * precision => $precision (optional) Sets the column's length and precision. The precision parameter is optional (though some column types may require it if the length is set). Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" owner Returns the "Alzabo::Create::Column" object that owns this definitions (the column that created it). perl v5.8.8 2007-12-23 Alzabo::Create::ColumnDefinition(3pm)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy