Summary: Help with awk script

From: himanshukhona (himanshukhona@indiatimes.com)
Date: Mon Feb 10 2003 - 00:09:18 EST


Hey all,

SImilar answers like one below.

I was making some syntax error.

Using printf with awk on the file & redirectingi t to an ew file solved the problem.

Thanks you all who reponded to very accurate answers.

Regards

Himanshu

"Brendan Gregg" wrote:

Hi Himanshu,

Have you tried something like,

awk '{ printf "%-8d %-8d %-8d %-8d %-8d\n",$1,$2,$3,$4,$5 }' file

This won't modify the original file, it will output to the screen. That
output can be redirected to a new file and moved over...

no worries,

Brendan

Standard Disclaimer: "Any opinions expressed are personal,
and do not necessarily reflect those of Sun Microsystems."

Brendan Gregg {
Brendan@Sun.COM # Level 3, 33 Berry St
Solaris Instructor # North Sydney, Australia
Sun Educational Services # +61 2 9466 9662 (x59662)
}

On Sat, 8 Feb 2003, himanshukhona wrote:

|Hey all,
|
|
|I have a file with say 5 columns with integers in all of them.
|I need to write a script which will modify the file such that each of
|the number is written with default 8 spaces allocated to it. For e.g.
|even if the number is 962, it will be left alligned & use up 8 spaces
|
|
|Its a small task. I tried many combinations of awk & printf.
|Pls help.
|TIA
|Himanshu
|
|Get Your Private, Free E-mail from Indiatimes at http://email.indiatimes.com
|Buy the best in Movies at http://www.videos.indiatimes.com
|Bid for Air Tickets @ Re.1 on Air Sahara Flights. Just log on to http://airsahara.indiatimes.com and Bid Now !
|_______________________________________________
|sunmanagers mailing list
|sunmanagers@sunmanagers.org
|http://www.sunmanagers.org/mailman/listinfo/sunmanagers
|

Get Your Private, Free E-mail from Indiatimes at http://email.indiatimes.com
Buy the best in Movies at http://www.videos.indiatimes.com
Bid for Air Tickets @ Re.1 on Air Sahara Flights. Just log on to http://airsahara.indiatimes.com and Bid Now !
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:25:47 EDT