How can i set column width in unix?

Reply

Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

How can i set column width in unix?

 
0
  #1
Oct 1st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,326
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 248
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How can i set column width in unix?

 
0
  #2
Oct 1st, 2008
Depends on the editor.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

Re: How can i set column width in unix?

 
0
  #3
Oct 1st, 2008
Originally Posted by masijade View Post
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,326
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 248
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How can i set column width in unix?

 
0
  #4
Oct 1st, 2008
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
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

Re: How can i set column width in unix?

 
0
  #5
Oct 1st, 2008
Originally Posted by masijade View Post
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..
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 61
Reputation: Gromit is an unknown quantity at this point 
Solved Threads: 7
Gromit's Avatar
Gromit Gromit is offline Offline
Junior Poster in Training

Re: How can i set column width in unix?

 
0
  #6
Oct 1st, 2008
This may be late, but I wanted to get the "column" command into the fight!

Shell Scripting Syntax (Toggle Plain Text)
  1. $ column -t -s " " test.txt
  2. aba bba baba
  3. abba baba baaa
  4. addd ffff fffff

Hope this helps!
-G
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC