The UNIX and Linux Forums  

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
recording command outputs in background jehrome_rando Shell Programming and Scripting 2 02-16-2009 05:13 PM
compare 2 outputs melanie_pfefer Shell Programming and Scripting 1 05-21-2008 10:20 AM
handling Multiline SQL outputs decci_7 Shell Programming and Scripting 5 01-08-2008 07:29 PM
How to set the File Paths for Inputs and Outputs Amruta Pitkar UNIX for Dummies Questions & Answers 1 10-31-2006 05:19 PM
I may have accidentally redefined one of the outputs... joang SUN Solaris 2 03-22-2005 10:12 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 12-27-2006
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
Printing outputs using awk.

I have a output of a command like this.

the command is : bdf|sed '/^e/d'|awk '{print$2/1048576}'
output :
0
0.515625
0.481979
2
2
2
7.8125
4
2
0.488281
7.8125
3.90625
4
1.95312
1
0.488281
15.625
7.8125
5.85938
0.20417
0.00119781
0.000595093
0.000587463
0.000587463
0.835808
0.206657
0.72831
0.000587463
0.000602722
0.000587463
1.73286
79.8446
6.20604
0.00723267
4.98518

i want to print only 2 digits after . please let me know how to do that?

thanks.
  #2 (permalink)  
Old 12-27-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
printf("%.2f\n", $2/1048576)

  #3 (permalink)  
Old 12-27-2006
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
The command worked great..but there is a slight change in the command ie; printf will also come inside the brazes.

thanks.

Last edited by Krrishv; 12-28-2006 at 02:58 AM..
  #4 (permalink)  
Old 01-09-2007
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
Thanks mates both the commands are working.
  #5 (permalink)  
Old 01-09-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960

Code:
sed 's/^.*\.\(..\)\(.*\)/\1/' filename

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:52 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