954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can i set column width in unix?

mY QUERY IS RELATED TO..

How can i set coloumn width in unix...

Like for ex. i am having a file, whose content is like

------------------------------
aba bba baba
abba baba baaa
addd ffff fffff
-----------------------------------
i want it to be like
-----------------------------------
aba bba baba
abba baba baaa
addd ffff fffff
------------------------------------
How can i set the coloumn width in unix... Please reply asap.
Thanks

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

Depends on the editor.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 
Depends on the editor.


i am using vi editor,....and want to send the file genrated as a mail...and want it to be in proper format

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

There is no "columns" There are tab sizes, but those only apply to the current session (also saved in preferences but only for the current user), so that doesn't help as the next person/viewer/editor won't have the same settings.

You best bet is, if your good at regex, to use search and replace to add in spaces. Even better, is to modify whatever "writes" the data to do that. Anyway, for vi, here:

http://www.cs.fsu.edu/general/vimanual.html

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

There is no "columns" There are tab sizes, but those only apply to the current session (also saved in preferences but only for the current user), so that doesn't help as the next person/viewer/editor won't have the same settings.

You best bet is, if your good at regex, to use search and replace to add in spaces. Even better, is to modify whatever "writes" the data to do that. Anyway, for vi, here:

http://www.cs.fsu.edu/general/vimanual.html

Here's the solution..
awk -F"~" '{printf("%-15s%s~%s\n", $1,$2,$3)}' inputfile
ID1 Name1~Place1
ID2 Name2~Place2
ID3 Name3~Place3

Thanks guys for your help..

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

This may be late, but I wanted to get the "column" command into the fight!

$ column -t -s " " test.txt 
aba   bba   baba
abba  baba  baaa
addd  ffff  fffff


Hope this helps!
-G

Gromit
Posting Whiz in Training
212 posts since Sep 2008
Reputation Points: 47
Solved Threads: 31
 

IN CSV format how to reduce the column width ...That means when we open csv file it looks like an excel format.when we click on A or B or c etc columns..The column is expanding.so i want to reduce the column width.How to do it give me an idea...

meduri
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

In general, hijacking a 3-year-old thread is not a good start.
As for your question, you decrease the width by putting less things in the cell.

If, on the other hand, you are reading a CSV file and the contents are being imported in another format you need to configure the import process to address your input file as the proper type.

L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You