columnating text


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers columnating text
# 1  
Old 01-09-2008
columnating text

I have a file /T, where the text of that file is:

1
2
3
4
5
6

I wish to change that to a two-column format

column </T --(output set to new document) gets:
1 2 3 4 5 6
which probably makes sense as I have no option and no argument.

column -c <T (output set to new document) yields nothing, which makes sense because I haven't specified an argument

column -c 2 </T -- (output set to new document) I expect

1 2
3 4
5 6

BUT get

1
2
3
4
5
6

It would seem I'm specifying the argument incorrectly. If that's true, what is the proper syntax?

And, if I can get past the above problem, what's the story with an -x option; it doesn't appear in the "man column" I've looked at, but elsewhere I've seen it stated that (with that option) I should get:

1 4
2 5
3 6

help? TIA
# 2  
Old 01-10-2008
I have never used this command before, but there's a first time for everything. Playing around a little I get...
Code:
$ column -c20 < ./T
1       4
2       5
3       6
$ column -c20 -x < ./T
1       2
3       4
5       6
$

# 3  
Old 01-10-2008
Hi.

I think the columns command is somewhat deceiving. The option "-c" does allow you to specify "columns", but it is the column-width of the display area, not "columns" of data.

A useful exercise might be to find the length of the file in lines, split the file, and use paste to read the splits -- provided the data fits into data-columns within the display-columns Smilie ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

3. Shell Programming and Scripting

Read text between regexps and write into files based on a field in the text

Hi, I have a huge file that has data something like shown below: huge_file.txt start regexp Name=Name1 Title=Analyst Address=Address1 Department=Finance end regexp some text some text start regexp Name=Name2 Title=Controller Address=Address2 Department=Finance end regexp (7 Replies)
Discussion started by: r3d3
7 Replies

4. Shell Programming and Scripting

Grep text matching problem with script which checks if web page contains text.

I wrote a Bash script which checks to see if a text string exists on a web page and then sends me an email if it does (or does not e.g. "Out of stock"). I run it from my crontab, it's quite handy from time to time and I've been using it for a few years now. The script uses wget to download an... (6 Replies)
Discussion started by: gencon
6 Replies

5. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

6. Shell Programming and Scripting

Search text from a file and print text and one previous line too

Hi, Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11 Thanks for your help. (6 Replies)
Discussion started by: kamranjalal
6 Replies

7. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

8. Shell Programming and Scripting

Adding specific text and spaces to each line in a text file

Hi, I wanted to add specific text to each row in a text file containing three rows. Example: 0 8 7 6 5 5 7 8 9 0 7 9 7 8 9 0 1 2 And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this: 21 0 8 7 6 5 5 7 8... (4 Replies)
Discussion started by: hertingm
4 Replies
Login or Register to Ask a Question