Sponsored Content
Top Forums Shell Programming and Scripting Help converting column to row for multiple files Post 302532336 by ctsgnb on Monday 20th of June 2011 04:08:40 PM
Old 06-20-2011
Code:
awk 'FNR==1{A[++a]=$4;next}{A[a]=A[a] OFS $4;next}END {while(A[++i]) print A[i]}' yourfile*.txt

---------- Post updated at 10:05 PM ---------- Previous update was at 10:04 PM ----------

Code:
[ctsgnb@shell ~/sand]$ ls f*.txt
f3.txt  f4.txt
[ctsgnb@shell ~/sand]$ cat f3.txt
104 "Congruent\blue_in_blue_1.bmp" 1037 1
104 "Congruent\blue_in_blue_1.bmp" 1225 1
104 "Congruent\blue_in_blue_2.bmp" 807 1
104 "Congruent\blue_in_blue_2.bmp" 960 1
104 "Congruent\blue_in_blue_3.bmp" 1061 1
104 "Congruent\blue_in_blue_3.bmp" 1214 1
[ctsgnb@shell ~/sand]$ cat f4.txt
204 "Congruent\blue_in_blue_2.bmp" 2037 2
204 "Congruent\blue_in_blue_2.bmp" 2225 2
204 "Congruent\blue_in_blue_2.bmp" 807 2
204 "Congruent\blue_in_blue_2.bmp" 960 2
204 "Congruent\blue_in_blue_3.bmp" 2062 2
204 "Congruent\blue_in_blue_3.bmp" 2224 2
[ctsgnb@shell ~/sand]$ awk 'FNR==1{A[++a]=$4;next}{A[a]=A[a] OFS $4;next}END {while(A[++i]) print A[i]}' f*.txt
1 1 1 1 1 1
2 2 2 2 2 2
[ctsgnb@shell ~/sand]$

---------- Post updated at 10:08 PM ---------- Previous update was at 10:05 PM ----------

if all your files have a fixed number of line (here : 6 lines) you can for example :

Code:
[ctsgnb@shell ~/sand]$ awk '{print $4}' f*.txt | xargs -n6
1 1 1 1 1 1
2 2 2 2 2 2
[ctsgnb@shell ~/sand]$

This User Gave Thanks to ctsgnb For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Column values to comma delimted single Row

I have a requirement in which i have to read a file which has multiple columns seperated by a pipe "|" from this i have to read each column values seperately and create a comma seperated row for the column and write to another file. eg: Input file: ColA ColB 1 2 2 x 3 y... (5 Replies)
Discussion started by: nvuradi
5 Replies

2. Shell Programming and Scripting

Converting Single Column into Multiple rows

i have single column which is starting with same string(many number of rows) i have to convert each into a single row.how can i do that? laknar std mes 23 55 laknar isd phone no address amount 99 I have to convert above like below. laknar|std|mes|23|55 laknar|isd|phone... (3 Replies)
Discussion started by: laknar
3 Replies

3. Shell Programming and Scripting

Converting values in a ROW to COLUMN

Hi All, I needd to convert values in a row to a column. eg: Input is as: value1,value2,value3,value4,.........,value N Required Output: Value1 Value2 Value3 . . . Value N Please help.... (3 Replies)
Discussion started by: sambaman
3 Replies

4. Shell Programming and Scripting

Converting Multiple rows to Single Row using unix commands

Can somebody help me in solving this.. Input data is like 0 A 1 B 2 C 3 D 0 A1 1 B1 2 C1 3 D1 0 A2 1 B2 2 C2 3 D2 Output should be like A B C D A1 B1 C1 D1 A2 B2 C2 D2 (7 Replies)
Discussion started by: Mahantesh Patil
7 Replies

5. Shell Programming and Scripting

converting column to row

Hi everyone.. I have a list of values in a file... 1.2345e-1 2.282828e+ 3.2341e-1 1.1223445e-1 I am interested in converting this column to a row.. 1.2345e-1 2.282828e+ 3.2341e-1 1.1223445e-1 can anyone pls help?? I am a liunx newbie.. Thanks.. (7 Replies)
Discussion started by: kjha
7 Replies

6. Shell Programming and Scripting

Combining multiple column files into one with file name as first row

Hello All, I have several column files like this $cat a_b_s1.xls 1wert 2tg 3asd 4asdf 5asdf $cat c_d_s2.xls 1wert 2tg 3asd 4asdf 5asdf desired put put $cat combined.txt s1 s2 (2 Replies)
Discussion started by: avatar_007
2 Replies

7. Shell Programming and Scripting

Converting Single Column into Multiple rows, but with strings to specific tab column

Dear fellows, I need your help. I'm trying to write a script to convert a single column into multiple rows. But it need to recognize the beginning of the string and set it to its specific Column number. Each Line (loop) begins with digit (RANGE). At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies

8. Shell Programming and Scripting

Converting a single row to multiple rows

Hi, I want to convert a single row values to multiple rows, but the no. of rows are not fixed. For example, I have a row as below abc-def-lmn-mno-xyz out put should be get abc get def get lmn get xyz (4 Replies)
Discussion started by: Suneel Mekala
4 Replies

9. Shell Programming and Scripting

Using loop command in UNIX for converting column to row

Dear folks I have 300 files which one of them are looking like: 1.SNP 0 0 1 0 I am looking for desire output: 1.SNP 0 0 1 0 I used this below command to run all of the 300 file at the same time for file in *.SNP; do awk '{printf( "%s ", $1 );} END {printf("\n");}' $file >... (1 Reply)
Discussion started by: sajmar
1 Replies

10. Shell Programming and Scripting

Row bind multiple csv files having different column headers

All, I guess by this time someone asked this kind of question, but sorry I am unable to find after a deep search. Here is my request I have many files out of which 2 sample files provided below. File-1 (with A,B as column headers) A,B 1,2 File-2 (with C, D as column headers) C,D 4,5 I... (7 Replies)
Discussion started by: ks_reddy
7 Replies
bitmap_mask_color(3alleg4)					  Allegro manual					bitmap_mask_color(3alleg4)

NAME
bitmap_mask_color - Returns the mask color of the specified bitmap. Allegro game programming library. SYNOPSIS
#include <allegro.h> int bitmap_mask_color(BITMAP *bmp); DESCRIPTION
Returns the mask color for the specified bitmap (the value which is skipped when drawing sprites). For 256-color bitmaps this is zero, and for truecolor bitmaps it is bright pink (maximum red and blue, zero green). A frequent use of this function is to clear a bitmap with the mask color so you can later use this bitmap with masked_blit() or draw_sprite() after drawing other stuff on it. Example: /* Replace mask color with another color. */ for (y = 0; y h; y++) for (x = 0; x w; x++) if (getpixel(bmp, x, y) == bitmap_mask_color(bmp)) putpixel(bmp, x, y, another_color); SEE ALSO
MASK_COLOR_8(3alleg4), set_color_depth(3alleg4), bitmap_color_depth(3alleg4), ex3d(3alleg4), exmouse(3alleg4), expat(3alleg4) Allegro version 4.4.2 bitmap_mask_color(3alleg4)
All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy