Home Man
Search
Today's Posts
Register

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

How do I sort data in column properly?

Tags
column, justify, standard

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 05-16-2018
How do I sort data in column properly?

Can i use 'column' command to get the required 3rd column output?

Input example:

Code:
1 2 345678 90
2 2 356       42
3 3 8265     55

Output required:

Code:
1 2 345678 90
2 2      356  42
3 3    8265  55

Basically i want the 3rd column to be justified to the right, instead of left. '>>column -t' command somehow makes it skewed to the left.

Thank you

Moderator's Comments:
How do I sort data in column properly? Please use CODE tags as required by forum rules!

Last edited by RudiC; 05-16-2018 at 04:10 AM.. Reason: Added CODE tags.
# 2  
Old 05-16-2018
Welcome to the forum.

How about
Code:
rev file | column -t | rev
1  2  345678  90
2  2     356  42
3  3    8265  55

Be aware that this will right justify every column.

Last edited by RudiC; 05-16-2018 at 05:35 AM..
The Following User Says Thank You to RudiC For This Useful Post:
nurul_nadzirah (05-16-2018)
# 3  
Old 05-16-2018
Thank you very much RudiC. Now, how do i output it into the new file?
# 4  
Old 05-17-2018
Quote:
Originally Posted by nurul_nadzirah
Thank you very much RudiC. Now, how do i output it into the new file?
What new file? There is no mention of a new file in post #1 in this thread?

What shell are you using?

What operating system are you using?

For many shells on many operating systems, the command:
Code:
rev oldfile | column -t | rev > newfile

would reformat the contents of a file named oldfile into a new file named newfile.
The Following User Says Thank You to Don Cragun For This Useful Post:
nurul_nadzirah (05-17-2018)
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with sort only column 2 data separately perl_beginner Shell Programming and Scripting 2 02-18-2016 04:05 AM
Sort data by date and then search by column samrat dutta Shell Programming and Scripting 2 05-17-2013 10:23 AM
Why is sort not working properly here ? kraljic Shell Programming and Scripting 8 03-12-2013 11:46 AM
Compare 2 files and match column data and align data from 3 column asnandhakumar Shell Programming and Scripting 5 10-16-2012 09:58 AM
Advanced: Sort, count data in column, append file name JamesT Shell Programming and Scripting 14 08-14-2012 07:36 AM
Sort data As per first Column pareshkp Shell Programming and Scripting 13 02-26-2012 01:16 PM
Sort data from column to row killerbee Shell Programming and Scripting 5 02-10-2012 04:50 PM
Align the values in column properly Indra2011 Shell Programming and Scripting 6 09-23-2011 12:28 PM
Sort a the file & refine data column & row format ckaramsetty Shell Programming and Scripting 7 09-08-2011 06:50 AM
Korn: How to zero fill df output so it will sort properly shew01 Shell Programming and Scripting 9 06-04-2008 10:34 AM


All times are GMT -4. The time now is 01:16 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password