Operations on columns of 2 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Operations on columns of 2 files
# 8  
Old 09-12-2008
Finaly It's work great.
Thanks a lot !
# 9  
Old 09-12-2008
Code:
paste -d"," file1 file2 > temp
awk '{
i=NF/2
for(j=1;j<=i;j++)
{
	t=j+i
	if(j<i)
		printf("%s,",$j-$t)
	else
		printf("%s",$j-$t) 
}
print ""
}' temp
rm temp

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies

2. Shell Programming and Scripting

Adding columns from 2 files with variable number of columns

I have two files, file1 and file2 who have identical number of rows and columns. However, the script is supposed to be used for for different files and I cannot know the format in advance. Also, the number of columns changes within the file, some rows have more and some less columns (they are... (13 Replies)
Discussion started by: maya3
13 Replies

3. Shell Programming and Scripting

Read and write operations on files.

Dears. kindly guide !!! I have data, which is delimited by | . it should contain 26 columns, but one column data contain | makes few row to 27 columns. I want to find rows have 27 columns and then concatenate the specific columns to single column to make it 26 columns. Kindly help, Can... (3 Replies)
Discussion started by: sadique.manzar
3 Replies

4. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

5. Shell Programming and Scripting

Sorting operations on several files

I have over 250 files (named grad.1000, grad.1001, grad.1002) - see attachment - that have this format: # 0.004 0.692758 # 6.23025467936 6.23025467936 6.23025467936 44.9620453206 44.9620453206 44.9620453206 # 0.8 1.19989 0.99914606306 1.0117015948 1.03761854021 1.07717125288 1.13095455063... (4 Replies)
Discussion started by: kayak
4 Replies

6. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

7. Shell Programming and Scripting

columns into different files

hello all, my input file(excel workbook) has the following structure mir-111 mir-222 mir-333 mir-444 abc,45 h,5 jhu,k jhg,111111 def,56 u,90 kil,10 k,0987 g,5 ki,09 huy,09 o,00000 j,7 molkijhn,88 erf,111 u,9876 k,8 kou,098 eef,122 jjj,kkkkkk now, i would like to break... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. Shell Programming and Scripting

Math operations with file columns values.

Hello everybody, I have some large files containing statistical data. The data is stored in the following generic format: >cat my_file 1, 2, 3 1, 2, 3 1, 2, 3 > The values of columns no.2 and 3 are expressed in bytes. I would like to transform them in Megabytes, by dividing them with... (3 Replies)
Discussion started by: fabian23
3 Replies

9. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

10. Shell Programming and Scripting

Matrix Operations of two files

Hi , I have two files aaa.txt (which contains) 1 2 3 4 5 6 7 8 9 10 11 12 and bbb.txt (which contains) -1 -2 -3 -4 -5 -6 5 -8 0 3 0 0 the output that I intended to have is 0 0 0 0 0 0 6 0 4.5 6.5 5.5 6 i.e. Averaging the script is in the file abc Begin{START of the... (2 Replies)
Discussion started by: narendra_linux
2 Replies
Login or Register to Ask a Question