Sponsored Content
Full Discussion: [Solved] Column manipulation
Top Forums UNIX for Dummies Questions & Answers [Solved] Column manipulation Post 302593162 by zajtat on Wednesday 25th of January 2012 11:23:39 PM
Old 01-26-2012
... there are no specs in the names of the columns or rows (the label looks like this: aaaa_bbbb)

My solution was to make files for each column with awk:
Code:
awk '{print $1, $2}' file1 > file2
awk '{print $1, $3}' file1 > file3
awk '{print $1, $4}' file1> file4
etc

then combine them with cat:

Code:
cat file2 file3 file4 > file 5

The problem is that I don't have the column's label in the first column and since there are a lot of columns it takes me forever even if I make a loop, not to mention the number of temporary files and cat commands. So, I was wondering if anyone had a better solution.

Many thanks for your time!

Last edited by methyl; 01-26-2012 at 07:45 AM.. Reason: please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Column manipulation

Hi, I have an input file in which I need to add a column with the value of part of another column. I.e. I have the following line (example, not the actual data): field1,field2,field3,test12,field5,field6I need to get the last two characters of the 4th field, and add them at the end as a... (5 Replies)
Discussion started by: Subbeh
5 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Deleting all rows where the first column equals the second column

Hi, I have a tab delimited text file where the first two columns equal numbers. I want to delete all rows where the value in the first column equals the second column. How do I go about doing that? Thanks! Input: 1 1 ABC DEF 2 2 IJK LMN 1 2 ZYX OPW Output: 1 2 ZYX OPW (2 Replies)
Discussion started by: evelibertine
2 Replies

3. Shell Programming and Scripting

[Solved] Sorting a column based on another column

hello, I have a file as follows: F0100010 A C F0100040 A G BTA-28763-no-rs 77.2692 F0100020 A G F0100030 A T BTA-29334-no-rs 11.4989 F0100030 A T F0100020 A G BTA-29515-no-rs 127.006 F0100040 A G F0100010 A C BTA-29644-no-rs 7.29827 F0100050 A... (9 Replies)
Discussion started by: Homa
9 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Text manipulation help

Hello Unix.com How can I sort from a large email list only the emails that finish with .ca domain? cat <list> | grep "\.ca\b" >> <new list> isnt working perfectly. Any tips? Best regards, Galford D. Weller (2 Replies)
Discussion started by: galford
2 Replies

5. Shell Programming and Scripting

Column manipulation and counter

Hello, I was wondering how I could change this input: cat f1 to produce this output: As you can tell, I have several unsorted repeating strings in col1 of the input file. Each of these strings has an associated word in col2. Col2 has a total of 4 possible words (go, stop,... (3 Replies)
Discussion started by: verse123
3 Replies

6. Shell Programming and Scripting

[Solved] awk manipulation of sequentially named files

Hello, I am a very novice user of awk, I have a set of files named file001, file002, file003, file004, etc., each contains four fields (columns of data) separated each by a uneven number of spaces. I want to substitute those spaces by a TAB, so I am using this line of awk script: awk -v OFS="\t"... (4 Replies)
Discussion started by: jaldo0805
4 Replies

7. Shell Programming and Scripting

Column manipulation

Hallo Team, I have a .csv file. I would like to have another column called Prefix. Under column Prefix i would like to have the first 3 numbers from the theird column. Other Licenced Operator Alpha Code Numbering Per minute Interconnect Fee per rate group (R Excluding VAT) ... (4 Replies)
Discussion started by: kekanap
4 Replies

8. Shell Programming and Scripting

[Solved] Data manipulation

Hallo Team, I need your help. I have a file that has two colums. See sample below: 105550 0.28 105550 0.24 125550 0.28 125550 0.24 215650 0.28 215650 0.24 315550 0.28 315550 0.24 335550 0.28 335550 0.24 40555 0.21 40555 0.17 415550 0.21 415550 0.17 43555 0.21 43555 0.17 (5 Replies)
Discussion started by: kekanap
5 Replies

9. UNIX for Advanced & Expert Users

Column manipulation of a file

In a space delimited file how would you go about removing 2 and 3 column of a file and add "word" to the first column of the file in both awk and vi? (2 Replies)
Discussion started by: cokedude
2 Replies

10. UNIX for Dummies Questions & Answers

Column manipulation

Hi, I's like to ask for help with the following question: this is an example file: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 I need to have it re-arranged in the following manner: first 2 columns, zero, zero, last two columns, columns 3 to... (6 Replies)
Discussion started by: zajtat
6 Replies
COMBINE(1)																COMBINE(1)

NAME
combine - combine sets of lines from two files using boolean operations SYNOPSIS
combine file1 and file2 combine file1 not file2 combine file1 or file2 combine file1 xor file2 _ file1 and file2 _ _ file1 not file2 _ _ file1 or file2 _ _ file1 xor file2 _ DESCRIPTION
combine combines the lines in two files. Depending on the boolean operation specified, the contents will be combined in different ways: and Outputs lines that are in file1 if they are also present in file2. not Outputs lines that are in file1 but not in file2. or Outputs lines that are in file1 or file2. xor Outputs lines that are in either file1 or file2, but not in both files. "-" can be specified for either file to read stdin for that file. The input files need not be sorted, and the lines are output in the order they occur in file1 (followed by the order they occur in file2 for the two "or" operations). Bear in mind that this means that the operations are not commutative; "a and b" will not necessarily be the same as "b and a". To obtain commutative behavior sort and uniq the result. Note that this program can be installed as "_" to allow for the syntactic sugar shown in the latter half of the synopsis (similar to the test/[ command). It is not currently installed as "_" by default, but you can alias it to that if you like. SEE ALSO
join(1) AUTHOR
Copyright 2006 by Joey Hess <joey@kitenet.net> Licensed under the GNU GPL. moreutils 2012-04-09 COMBINE(1)
All times are GMT -4. The time now is 05:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy