The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 |
Newsgroups: comp.lang.awk, comp.unix.shell
From: Farid Hamjavar <hamja...@unm.edu>
Date: Tue, 27 Nov 2007 15:08:02 -0700
Local: Tues, Nov 27 2007 5:08 pm
Subject: formatting question...
Hello, My un-formatted data file: 2007-10 14,807 1,604 29,600 2007-09 15,173 521 35,853 2007-08 12,799 1,236 516 2007-07 5,780 416 37,135 I run it through: cat file| awk '{printf "%-11s%-7s%-9s%s\n",$1,$2,$3,$4}' and get: [I hope you use ASCII friendly mail/news-reader client] 2007-10 14,807 1,604 29,600 2007-09 15,173 521 35,853 2007-08 12,799 1,236 516 2007-07 5,780 416 37,135 But what I want is: i.e. entries in col# 2,3,4 line up on the 3-digit bound Eries: 2007-10 14,807 1,604 29,600 2007-09 15,173 521 35,853 2007-08 12,799 1,236 516 2007-07 5,780 416 37,135 Anything I can do to get this format? Thanks, Farid
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
Newsgroups: comp.lang.awk, comp.unix.shell
From: Ed Morton <mor...@lsupcaemnt.com>
Date: Tue, 27 Nov 2007 16:13:43 -0600
Local: Tues, Nov 27 2007 5:13 pm
Subject: Re: formatting question...
On 11/27/2007 4:08 PM, Farid Hamjavar wrote: > Hello, > My un-formatted data file: > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > I run it through: > cat file| awk '{printf "%-11s%-7s%-9s%s\n",$1,$2,$3,$4}'
UUOC: awk '{printf "%-11s%-7s%-9s%s\n",$1,$2,$3,$4}' file
> and get: > [I hope you use ASCII friendly mail/news-reader client] > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > But what I want is: > i.e. entries in col# 2,3,4 line up on the > 3-digit bound Eries: > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > Anything I can do to get this format?
Yes, get rid of the "-" signs tellling printf to push everything to the left, e.g.: $ awk '{printf "%7s%9s%9s%9s\n",$1,$2,$3,$4}' file 2007-10 14,807 1,604 29,600 2007-09 15,173 521 35,853 2007-08 12,799 1,236 516 2007-07 5,780 416 37,135 Regards, Ed.
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
Newsgroups: comp.lang.awk, comp.unix.shell
Followup-To: comp.unix.shell
From: Bill Marcum <marcumb...@bellsouth.net>
Date: Tue, 27 Nov 2007 17:29:42 -0500
Local: Tues, Nov 27 2007 5:29 pm
Subject: Re: formatting question...
["Followup-To:" header set to comp.unix.shell.] On 2007-11-27, Farid Hamjavar <hamja...@unm.edu> wrote:
> Hello, > My un-formatted data file: > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > I run it through: > cat file| awk '{printf "%-11s%-7s%-9s%s\n",$1,$2,$3,$4}' > and get: > [I hope you use ASCII friendly mail/news-reader client] > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > But what I want is: > i.e. entries in col# 2,3,4 line up on the > 3-digit bound Eries: > 2007-10 14,807 1,604 29,600 > 2007-09 15,173 521 35,853 > 2007-08 12,799 1,236 516 > 2007-07 5,780 416 37,135 > Anything I can do to get this format?
The '-' in %-99s tells printf to print aligned left, and you want the fields aligned right.
You must Sign in before you can post messages.
You do not have the permission required to post.
|
|
|