Sponsored Content
Top Forums Shell Programming and Scripting Compare Two Files(Column By Column) In Perl or shell Post 302545678 by danmero on Tuesday 9th of August 2011 07:07:43 AM
Old 08-09-2011
Look like a homework , please read the forum rules.

You can use the shell parameter expansions to segment your records:
Code:
# for file in file[1,2].txt;do while read line;do echo $file ${line:0:5} ${line:5:4};done < $file;done
file1.txt 8888 12341
file1.txt 1243 48895
file1.txt 8945 96789
file1.txt 1111 11111
file2.txt 9578 56789
file2.txt 8945 89789
file2.txt 5789 67895
file2.txt 1111 11111

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare Column value from Two Different Files

Hi, I need help to write a korn shell script to 1. Check and compare the first file contains single record from the /scp/inbox directory against the badpnt.dat file from the pnt/badfiles directory contains multiple records based on the fam_id column value start at position 38 to 47 from the... (7 Replies)
Discussion started by: hanie123
7 Replies

2. Shell Programming and Scripting

column compare of files

Hi i want to compare files a.txt 12345,23 34567,76 65456,10 13467,01 b.txt 12346,23 34567,76 23333,90 65456,10 13467,03 i want o/p in 3 files common.txt both have (2 Replies)
Discussion started by: aaysa123
2 Replies

3. Shell Programming and Scripting

Compare files column to column based on keys

Here is my situation. I need to compare two tab separated files (diff is not useful since there could be known difference between files). I have found similar posts , but not fully matching.I was thinking of writing a shell script using cut and grep and while loop but after going thru posts it... (2 Replies)
Discussion started by: blackjack101
2 Replies

4. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

5. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

6. Shell Programming and Scripting

How to compare 2 files column's more than 5?

Hi All I am just trying to compare 2 file using column information using following code awk ' NR==FNR {A=$9; next} {B=A; print $0,B""?B:" Not -In file" } ' OFS="\t" file1 file2if file1 matches with file2 then print $9 content in file 1 along with file2 $0 suppose if I keyed on only $1 in... (17 Replies)
Discussion started by: Akshay Hegde
17 Replies

7. Shell Programming and Scripting

Compare 1 column in 2 files

Hi all, I have two two-column tab-separated files with the following input: inputA dog A dog B cat A.... inputB dog C mouse A output dog I need to compare the 1st column of each file and output those shared items. What is the best unix solution for that? (5 Replies)
Discussion started by: owwow14
5 Replies

8. Shell Programming and Scripting

Help with compare two column and print out column with smallest number

Input file : 5 20 500 2 20 41 41 0 23 1 Desired output : 5 2 20 0 1 By comparing column 1 and 2 in each line, I hope can print out the column with smallest number. I did try the following code, but it don't look good :( (2 Replies)
Discussion started by: perl_beginner
2 Replies

9. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to compare 3rd column value with first column and display

Hello Team, My source data (INput) is like below EPIC1 router EPIC2 Targetdefinition Exp1 Expres rtr1 Router SQL SrcQual Exp1 Expres rtr1 Router EPIC1 Targetdefinition My output like SQL SrcQual Exp1 Expres Exp1 Expres rtr1 Router rtr1 Router EPIC1 Targetdefinition... (5 Replies)
Discussion started by: sekhar.lsb
5 Replies
Alzabo::Create::Index(3pm)				User Contributed Perl Documentation				Alzabo::Create::Index(3pm)

NAME
Alzabo::Create::Index - Index objects for schema creation SYNOPSIS
use Alzabo::Create::Index; DESCRIPTION
This object represents an index on a table. Indexes consist of columns and optional prefixes for each column. The prefix specifies how many characters of the columns should be indexes (the first X chars). Some RDBMS's do not have a concept of index prefixes. Not all col- umn types are likely to allow prefixes though this depends on the RDBMS. The order of the columns is significant. INHERITS FROM
"Alzabo::Index" Note: all relevant documentation from the superclass has been merged into this document. METHODS
new The constructor takes the following parameters: * table => "Alzabo::Create::Table" object The table that this index is indexing. * columns => [ "Alzabo::Create::Column" object, .. ] * columns => [ { column => "Alzabo::Create::Column" object, prefix => $prefix }, repeat as needed ... ] This parameter indicates which columns that are being indexed. It can either be an array reference of column objects, or an array ref- erence of hash references, each with a key called column and one called prefix. The prefix key is optional. * unique => $boolean Indicates whether or not this is a unique index. * fulltext => $boolean Indicates whether or not this is a fulltext index. * function => $string This can be used to create a function index where supported. The value of this parameter should be the full function, with column names, such as "LCASE( username )". The "columns" parameter should include all the columns used in the function. Returns a new "Alzabo::Create::Index" object. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" table Returns the "Alzabo::Create::Table" object to which the index belongs. columns Returns an ordered list of the "Alzabo::Create::Column" objects that are being indexed. add_column Adds a column to the index. This method takes the following parameters: * column => "Alzabo::Create::Column" object * prefix => $prefix (optional) Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" delete_column ("Alzabo::Create::Column" object) Deletes the given column from the index. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" prefix ("Alzabo::Create::Column" object) A column prefix is, to the best of my knowledge, a MySQL specific concept, and as such cannot be set when using an RDBMSRules module for a different RDBMS. However, it is important enough for MySQL to have the functionality be present. It allows you to specify that the index should only look at a certain portion of a field (the first N characters). This prefix is required to index any sort of BLOB column in MySQL. This method returns the prefix for the column in the index. If there is no prefix for this column in the index, then it returns undef. set_prefix This method takes the following parameters: * column => "Alzabo::Create::Column" object * prefix => $prefix Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" unique Returns a boolean value indicating whether the index is a unique index. set_unique ($boolean) Sets whether or not the index is a unique index. fulltext Returns a boolean value indicating whether the index is a fulltext index. set_fulltext ($boolean) Set whether or not the index is a fulltext index. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" register_column_name_change This method takes the following parameters: * column => "Alzabo::Create::Column" object The column (with the new name already set). * old_name => $old_name This method is called by the table object which owns the index when a column name changes. You should never need to call this yourself. Throws: "Alzabo::Exception::Params" id The id is generated from the table, column and prefix information for the index. This is useful as a canonical name for a hash key, for example. Returns a string that is the id which uniquely identifies the index in this schema. AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Create::Index(3pm)
All times are GMT -4. The time now is 01:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy