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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Alter string in 2nd column of line Orbix Shell Programming and Scripting 3 12-28-2008 05:11 AM
Need to get the first column of data bobk544 Shell Programming and Scripting 3 08-04-2007 05:35 PM
How to write data in column c0384 Shell Programming and Scripting 8 07-28-2007 06:18 PM
Column data reading FarhanNaseer Shell Programming and Scripting 1 09-19-2005 01:02 AM
glance RSS/VSS data column xtrix HP-UX 0 01-17-2005 10:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-02-2009
tintin72 tintin72 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 23
alter data in column

Hello All,

I want to alter the first column of a dataset, say,

Code:
 
001 0.700 100.000
002 0.715 99.998
003 0.730 99.998
004 0.744 99.975
005 0.759 99.916
011 0.847 97.987 
012 0.861 97.317 
020 0.978 87.789
021 0.993 86.400
022 1.008 84.904
023 1.022 83.014
100 2.148 11.426
101 2.162 11.146
such that it reads

Code:
 
1.0 0.700 100.000
2.0 0.715 99.998
3.0 0.730 99.998
4.0 0.744 99.975
5.0 0.759 99.916
11.0 0.847 97.987 
12.0 0.861 97.317 
20.0 0.978 87.789
21.0 0.993 86.400
22.0 1.008 84.904
23.0 1.022 83.014
100.0 2.148 11.426
101.0 2.162 11.146
in other words, all numbers in the first column are changed from integer to floating by removing zeros if it is a first character and adding a decimal point. Can someone shown me what syntax to use?

Thanks
  #2 (permalink)  
Old 04-02-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

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

Code:
awk '{$1=sprintf("%.1f",$1)}1' file > newfile
Regards
  #3 (permalink)  
Old 04-02-2009
tintin72 tintin72 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 23
it worked! thanks.
Closed Thread

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 08:29 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