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
Cannot store integer value bennichan Shell Programming and Scripting 5 04-10-2008 02:20 PM
get integer part ericaworld Shell Programming and Scripting 3 05-29-2007 03:16 PM
how to pass integer ramneek IP Networking 1 08-25-2005 08:40 AM
awk or grep for integer only apalex UNIX for Dummies Questions & Answers 5 09-01-2004 01:38 PM
add comma alisevA3 UNIX for Dummies Questions & Answers 3 10-18-2002 09:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-24-2008
Nutter Nutter is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 1
Smile Add comma to integer using AWK

Srr for being pain her
let say i have a data in a file like this

1@1000
2@2000
4@4000
5@7770
6@8998
7@80008

i am a newbie in Unix
i need to add a comma to integer using AWK function. for example, 1,000 or 80,008
how can i do that

ps. i'm using bash shell
  #2 (permalink)  
Old 08-25-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,861
Assuming your locale supports thousands separators (and many do not) and you are using gawk (GNU awk) and not awk or nawk the following will do what you want

Code:
$ cat t.awk
{ printf "%d@%'d\n", $1, $2 }
$
$ cat file
1@1000
2@2000
4@4000
5@7770
6@8998
7@80008
$
$ gawk -F@ -f t.awk file
1@1,000
2@2,000
4@4,000
5@7,770
6@8,998
7@80,008
$
Sponsored Links
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 06:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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