The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sorting data from a to z cosmologist UNIX for Dummies Questions & Answers 2 08-12-2009 04:01 PM
PERL data - sorting eagercyber Shell Programming and Scripting 3 06-20-2008 03:02 AM
sorting data from who by IP raidzero UNIX for Dummies Questions & Answers 11 06-19-2008 09:56 AM
Sorting your data with msort iBot UNIX and Linux RSS News 0 05-19-2008 11:20 AM
Newbie Awk data sorting i_am_a_robot Shell Programming and Scripting 5 05-04-2007 07:33 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
admax's Avatar
admax admax is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 6
Sorting the data right justified with through awk.

Dear all,
I have a inputfile like some what like this -


1000.98651
1000.96696
999.98904
991.66864
986.51829
986.49467
17.44122
16.74039
16.74021
10.92725

desired output

1000.98651
1000.96696
0999.98904
0991.66864
0986.51829
0986.49467
0017.44122
0016.74039
0016.74021
0010.92725

so that i can sort this in ascending order using sort -n.
thanks in advance.

Last edited by admax; 1 Week Ago at 09:18 AM..
  #2 (permalink)  
Old 1 Week Ago
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,502
so what's your problem? they both look the same to me.
  #3 (permalink)  
Old 1 Week Ago
admax's Avatar
admax admax is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 6
sorry, that was formatting error.

now i think it looks clear.
  #4 (permalink)  
Old 1 Week Ago
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,291
Try this:

Code:
awk -F"." '{printf("%0.4d.%s\n",$1, $2)}' file
  #5 (permalink)  
Old 1 Week Ago
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
Code:
awk -F"." '{printf("%04s.%s\n",$1,$2)}'
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0