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 Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
append zero's in the begining ganapati UNIX for Dummies Questions & Answers 3 01-17-2008 12:41 PM
Adding a new HDD jeffreydavisjr UNIX for Dummies Questions & Answers 5 10-16-2006 03:13 PM
adding licenses andryk SUN Solaris 0 05-19-2004 10:26 AM
Adding 2 numbers Viper01 Shell Programming and Scripting 7 04-17-2004 12:59 PM
Leading Zero's dbrundrett Shell Programming and Scripting 5 12-19-2003 09:15 AM

Closed Thread
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 07-21-2008
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
adding zero's

Hi
I am comparing two files, 100th column have formatting issue
i mean 1 file have scale 4 and anothe file scale 2 ,if scale 2 need to add two zeros.Please any idea how to add two zers to 100th coulmn if scale is 2

file 1
.................1234.2000

file2

................1234.20

Thanks,
MR
  #2 (permalink)  
Old 07-21-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink printf reformats output, or can do a bc function

Code:
> x1=1234.20
> echo $x1
1234.20
> echo $(printf "%.4f" "$x1")
1234.2000
something else to think about

Code:
> x2=1234.2000
> x3=$(echo "$x1"-"$x2" | bc)
> echo $x3
0
Perhaps one of these approaches will help you.
  #3 (permalink)  
Old 07-21-2008
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
Hi
Thanks for your reply .when comparing two files this 100th filed giving differences due to formatting issue .Is there any way to achive using sed or awk

Thanks in advance
MR
  #4 (permalink)  
Old 07-21-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Force awk to compare the string numerically...

Code:
echo 1234.2000 | awk '{print $0+0}'
1234.2
echo 1234.20 | awk '{print $0+0}'
1234.2
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 10:08 AM.


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