![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Formatting Output | dhanamurthy | Shell Programming and Scripting | 6 | 05-02-2008 08:43 AM |
| Formatting bdf output | Cameron | Shell Programming and Scripting | 5 | 04-09-2008 06:05 AM |
| formatting output | balaji_prk | Shell Programming and Scripting | 4 | 09-15-2007 06:23 AM |
| Formatting output | illur81 | Shell Programming and Scripting | 3 | 10-13-2005 06:24 AM |
| Formatting the output | Cameron | Shell Programming and Scripting | 7 | 02-15-2002 07:30 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help on formatting output (Table Form)
Data in File
ABC ABCZYE ABCFGD ABCEERRRRR Expected Format 1 ABC DEFGHIFE 123 2 ABCZYE DEFI 123 3 ABCFGD DEF 123 4 ABCEERRRRR DEFGHI 123 However when i enter the following command: awk 'BEGIN {FS=":"}{printf("%u %s\t%s\t%s\n", NR, $1, $2, $3)} END {print "End List"}' data.txt Actual Output 1 ABC DEFGHIFE 123 2 ABCZYE DEFI 123 3 ABCFGD DEF 123 4 ABCEERRRRR DEFGHI 123 how can i set the width of each column? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
get rid of the tabs and use the field width within printf. check the man page for details.
ie: Code:
printf "%20s\n" blah Code:
Field Width:
An optional digit string specifying a field width; if the output
string has fewer characters than the field width it will be blank-
padded on the left (or right, if the left-adjustment indicator has
been given) to make up the field width (note that a leading zero is
a flag, but an embedded zero is part of a field width);
also - please use the code tags around your code/data. That way we do not see smiley faces in the middle of your data. |
|
#3
|
|||
|
|||
|
thank you very much.
|
|||
| Google The UNIX and Linux Forums |