Sponsored Content
Top Forums Shell Programming and Scripting concatenate 'n' number of columns in a file Post 302460425 by kurumi on Wednesday 6th of October 2010 07:24:19 PM
Old 10-06-2010
Code:
$ ruby -ane 'puts $_.split.join(" ")' file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find number of columns in a file

Hi all, may seem a very stupid question.but me stuck up in it for long.... How to find the number of columns in a ASCII file. EX:-Demo.lst songs 1 34 45 67 Number of columns should be 5. Regards, Anindya ;) (13 Replies)
Discussion started by: rahul26
13 Replies

2. Shell Programming and Scripting

Print columns in a file by number list in another file

This should follow with my last post but I think it's better to start a new one. Now I have a list of numbers stored in pos.txt: 2 6 7 . . . n . . . And I need to extract (2n-1, 2n) columns from matrix.txt: ind1 A B C D E F G H I J K L M N O P Q R ... ind2 B C D E F G H... (3 Replies)
Discussion started by: Zoho
3 Replies

3. Shell Programming and Scripting

Concatenate columns from files

Hi, I have a file1.txt like this: and a file2.txt like this: I wat only append file2.txt to file1.txt and to have something like this: How could i do ? (2 Replies)
Discussion started by: AdminLew
2 Replies

4. Shell Programming and Scripting

Concatenate columns from multiple files

Hi all, I want the 2nd column of every file in the directory in a single file with the file name as column header. $cat file1.txt a b c d e f $cat file2.txt f g h g h j $cat file3.txt a b d f g h (2 Replies)
Discussion started by: newbie83
2 Replies

5. UNIX for Dummies Questions & Answers

Concatenate two columns and separate by - (minus)

hi all could you please help me to concatenate two colomns and separate them by "-" the two colomns to concatenate are colomuns 1 and 3 of a very bif file clomn 1 is chr, 2 is snp and 3 is bp the new colomn is chr_B input file : 1 rs1111 10583 1 rs1891 10611 1 rs1807 ... (13 Replies)
Discussion started by: biopsy
13 Replies

6. AIX

How to find number of columns in xml file?

How to find the number of columns in xml file. i tried following command. Code: #!bin/ksh cat $1 | grep -c "</mdm:attribute>"exit 0but i am not getting accurate result which is not matching with the manual count. data format : Code: <mdm:attribute> value </mdm:attribute> No... (1 Reply)
Discussion started by: victory
1 Replies

7. Shell Programming and Scripting

Number of columns in xml file

How to find the number of columns in xml file. i tried following command. #!bin/ksh cat $1 | grep -c "</mdm:attribute>" exit 0 but i am not getting accurate result which is not matching with the manual count. data format : <mdm:attribute> value </mdm:attribute> (6 Replies)
Discussion started by: victory
6 Replies

8. Shell Programming and Scripting

Grouping multiple columns and concatenate

I have a CSV file that goes like this: Name,Group,Email Max,Group1,max@.com Dan,Group2,dan@.com Max,Group3,max@.com Max,Group4,max@.com Dan,Group5,dan@.com Jim,Group6,jim@.comBasically my desired output should be: Name,Group,Email Max,Group1|Group3|Group4,max@.com... (6 Replies)
Discussion started by: jeffreybsu
6 Replies

9. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

10. Shell Programming and Scripting

Concatenate two columns in a file

Hi i am having one requirement like to concatenate two columns in to one columns, can any one help on this please sample scenario i am placing below COL1,COL2,COL3,COL4 1,A,B,C,D 2,e,f,g,h ouput should be 3 columns like below. COL1,COL2,newcolumns 1,A,B,CD 2,e,f,gh ... (9 Replies)
Discussion started by: bhaskar v
9 Replies
SUBTLEXT(1)															       SUBTLEXT(1)

NAME
subtlext - a ruby extension for subtle SYNOPSIS
subtlext DESCRIPTION
subtlext is an extension that brings the power of subtler to Ruby. A compending list of the classes with it's functionality can be found in rdoc and informations about the available unit tests in the devel- opment section. EXAMPLE
require("subtle/subtlext") puts "subtle %s on %s" % [Subtlext::Subtle.version, Subtlext::Subtle.running? ? Subtlext::Subtle.display : "none"] puts "Tags: %s" % [Subtlext::Tag[:all].join(", ")] # Views views = [] Subtlext::View[:all].each do |v| views.push("%s (%s)" % [v.current? ? "[#{v}]" : v, v.tags.join(", ")]) end puts "Views: %s" % [views.join(", ")] # Clients clients = [] Subtlext::Client[:all].each do |c| clients.push("%s (%s)" % [c, c.tags.join(", ")]) end puts "Clients: %s" % [clients.join(", ")] OUTPUT
subtle 0.8.1684 on :0.0 Tags: default, test, void, terms, browser, editor, stick, float, eight, two, seven, one, bashrun, sakura, python Views: terms (terms, eight, two), [www] (browser, eight, two), void (default, void, eight, two), editor (test, editor, seven, one) Clients: urxvt2 (two, one), urxvt1 (eight, seven), subtle - Subtlext - Redmine - Vimperator (browser), Xephyr on :2.0 (ctrl+shift grabs mouse and keyboard) (test, float), event.c (~/projects/subtle/src/subtle) - GVIM (editor) BUGS
Report bugs at http://subforge.org/projects/subtle/issues Homepage: http://subtle.subforge.org COPYRIGHT
Copyright (c) Christoph Kappel unexist@subforge.org SEE ALSO
subtle(1), subtler(1), sur(1), surserver(1) October 2011 SUBTLEXT(1)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy