columns into different files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting columns into different files
# 1  
Old 06-11-2012
columns into different files

hello all,

my input file(excel workbook) has the following structure

Code:
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 each mir columns into separate files and process the separate files with comma as delimiter and print $1 in upper case letters

so , now my output files will be as follows

Code:
mir-111_op.txt
ABC
DEF
G
J
K

Code:
mir-222_op.txt
H
U
KI
MOLKIJHN
KOU

Code:
mir-333_op.txt
JHU
KIL
HUY
ERF
EEF

Code:
mir-444_op.txt
JHG
K
O
U
JJJ

All helps appreciated. thanks in advance.
# 2  
Old 06-11-2012
What have you tried so far and where are you stuck?
# 3  
Old 06-11-2012
Hi Scrutinizer,

I tried the following

Code:
awk '{print $1} input.txt > mir-111_op.txt

Code:
awk -F"," '{print toupper($1)}'  mir-111_op.txt > test && mv test mir-111_op.txt

I am able to run individual column by column, but not being able to run a single code for the whole excel file.

Thanks in advance
# 4  
Old 06-11-2012
OK, if you use , as a field separator, it is going to be difficult to split it again later.. Try this:
Code:
awk 'NR==1{split($0,F); next}{for(i=1;i<=NF;i++){f=F[i] "_op.txt"; split($i,C,/,/); print toupper(C[1])>f}}' infile

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

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

4. Shell Programming and Scripting

Merge columns on different files

Hello, I have two files that have this format: file 1 86.82 0.00 86.82 43.61 86.84 0.00 86.84 43.61 86.86 0.00 86.86 43.61 86.88 0.00 86.88 43.61 file 2 86.82 0.22 86.84 0.22 86.86 0.22 86.88 0.22 I would like to merge these two files such that the final file looks like... (5 Replies)
Discussion started by: kayak
5 Replies

5. Shell Programming and Scripting

Match columns several files

Hey fellas! Here come my problem. I appreciate if you have a look at it. I have several files with following structure: file_1:1 21 4 45 file_2:2 31 4 153 6 341 and so on... and I have a 'reference' file look like this: File_ref:A 1 B 2 C 3 (5 Replies)
Discussion started by: @man
5 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

Merge columns of different files

Hi, I have tab limited file 1 and tab limited file 2 The output should contain common first column vales and corresponding 2nd column values; AND also unique first column value with corresponding 2nd column value of the file that contains it and 0 for the second file. the output should... (10 Replies)
Discussion started by: polsum
10 Replies

8. Shell Programming and Scripting

matching columns from two files

Hey, I have two files that have exactly the same format. They are both tab-delimited and contain 12 columns. However the # of rows vary. What I want to do is match columns # 5,6 and 7 between the two files. If they do match exactly (based on numbers) then I want the whole row from file 2 to... (1 Reply)
Discussion started by: phil_heath
1 Replies

9. Shell Programming and Scripting

columns manipulation in different files

Hi all, I have 3 files with data as : 1.txt 1 1 1 5 2.txt -5 1 0 3 3.txt 0 1 0 (1 Reply)
Discussion started by: AKD
1 Replies

10. 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
Login or Register to Ask a Question