Sponsored Content
Top Forums Shell Programming and Scripting Combine columns from many files but keep them aligned in columns-shorter left column issue Post 302738837 by isildur1234 on Monday 3rd of December 2012 01:49:38 AM
Old 12-03-2012
Thank you so much. This is working and aligning the columns correctly!
If you have time, can youvery very briefly explain how it works, why your for statements manage to align the columns, especially what happens at the printf?
for (j=1;j<=m;j++) {
for (i=0;i<fc;i++) {
printf (a[i,j])? (a[i,j] "\t"):("\t\t");


awk seems to be a very powerful language for file manipulation. How did you learn it? Textbook or website?
Again, thank you so much.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output columns needs to be aligned

Hi All I'm running a shell script and the output is something like: Col1 Col2 Col3 aaaa aaaaaaa aaaaa bbbbb bbbbb bbbbbb ccc cccccc ccccccc But I require the output to printed as given below: Col1 Col2 Col3 aaaa ... (4 Replies)
Discussion started by: nkamalkishore
4 Replies

2. Shell Programming and Scripting

How to combine 2 files into 1 file with 2 columns

Hi Guys, I want to combine 2 files and and put together in 1 file and make two columns out it. See below desired output. Any help will be much appreciated. inputfile1.txt 12345 67890 24580 inputfile2.txt AAAAA BBBBB CCCCC (11 Replies)
Discussion started by: pinpe
11 Replies

3. UNIX for Dummies Questions & Answers

How to combine 2 files with 6 columns?

This may seem obvious but I am having problems doing this as columns get converted to rows when i try to write a script. I have 2 files text1.txt and text2.txt each of which have 6 columns of numbers separated by a space. I need to combine the 2 files so that the output file text3.txt maintains... (2 Replies)
Discussion started by: tgoldstone
2 Replies

4. Shell Programming and Scripting

Combine columns from multiple files

Can anybody help on the script to combine/concatenate columns from multiple files input1 4 135 5 185 6 85 11 30 16 72 17 30 21 52 22 76 input2 2 50 4 50 6 33 8 62 10 25 12 46 14 42 15 46output (2 Replies)
Discussion started by: sdf
2 Replies

5. Shell Programming and Scripting

Merging columns based on one or more column in two files

I have two files. FileA.txt 30910 rs7468327 36587 rs10814410 91857 rs9408752 105797 rs1133715 146659 rs2262038 152695 rs2810979 181843 rs3008128 182129 rs3008131 192118 rs3008170 FileB.txt 30910 1.9415219673 0 36431 1.3351312477 0.0107191428 36587 1.3169171182... (2 Replies)
Discussion started by: genehunter
2 Replies

6. UNIX for Dummies Questions & Answers

Combine columns from 100 files with same structure

Hi, I have a bunch of files with the following format. PUR.1.9 30910 0.024 0.926 0.050 36587 0.024 0.927 0.049 91857 0.023 0.928 0.049 105797 0.024 0.927 0.049 146659 0.024 0.927 0.049 152695 0.024 0.927 0.049 192118 0.022 0.930 0.048 193310 0.018 0.936 0.046 PUR.2.9 30910 0.028... (6 Replies)
Discussion started by: genehunter
6 Replies

7. Shell Programming and Scripting

Merge two columns from two files into one if another column matches

I have two text files that look something like this: A:B:C 123 D:E:F 234 G:H:I 345 J:K:L 123 M:N:O 456 P:Q:R 567 A:B:C 456 D:E:F 567 G:H:I 678 J:K:L 456 M:N:O 789 P:Q:R 890 I want to find the line where the first column matches and then combine the second columns into a single... (8 Replies)
Discussion started by: pbluescript
8 Replies

8. 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

9. 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

10. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies
NUMSUM(1)						User Contributed Perl Documentation						 NUMSUM(1)

NAME
numsum - numsum program file SYNOPSIS
numsum [-iIcdhrsvxy] <FILE> | numsum [-iIcdhrsvxy] (Input on STDIN from pipeline.) numsum [-iIcdhrsvxy] (Input on STDIN. Use Ctrl-D to stop.) DESCRIPTION
numsum will take all the numbers on stdin and return the sum of those numbers. Currently it only processes the first number on each line. Besides positive numbers, it also handles negative numbers and numbers with decimals. OPTIONS
-i Only return the integer portion of the final sum. -I Only return the decimal portion of the final sum. -c Print out the sum of each column. -r Print out the sum of each row. -x <n> Specify a comma seperated list of columns to print. -y <n> Specify a comma seperated list of rows to print. -s <string> Specify a string to use as a seperator for columns. This defaults to be consecutive whitespace (s+). -h Help: You're looking at it. -V Increase verbosity. -d Debug mode. For developers -q Quiet mode, don't print any warnings. EXAMPLES
Simply add up the numbers in a file. $ numsum numbers.txt 4315 Enter your own numbers on STDIN. The last number is the answer. $ numsum 4 21 98 100 223 Use it in a command pipeline. $ ls -1s | grep .mp3 | numsum -c -x 5 72288 Add up the total byte count in a http log file. $ cat access_log | awk {'print $10'} numsum or numsum -c -x 10 access_log Add up the columns of numbers of a file. $ cat columns 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25 $ numsum -c columns 15 40 65 90 115 Add up the 1st, 2nd and 5th columns only. $ numsum -c -x 1,2,5 columns 15 40 115 Add up the rows of numbers of a file. $ numsum -r columns 55 60 65 70 75 Add up the 2nd and 4th rows. $ numsum -r -y 2,4 columns 60 70 SEE ALSO
numaverage(1), numbound(1), numinterval(1), numnormalize(1), numgrep(1), numprocess(1), numrandom(1), numrange(1), numround(1) COPYRIGHT
numsum is part of the num-utils package, which is copyrighted by Suso Banderas and released under the GPL license. Please read the COPYING and LICENSE files that came with the num-utils package Developers can read the GOALS file and contact me about providing submitions or help for the project. MORE INFO
More info on numsum can be found at: http://suso.suso.org/programs/num-utils/ perl v5.10.1 2009-10-31 NUMSUM(1)
All times are GMT -4. The time now is 12:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy