How to design the table in awk?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
My input file is file1
count month
505 Apr-2010
252 Mar-2010
426 Feb-2010
201 Jan-2010
211 Dec-2009
Same file I want the output like this below
+-------+----------+
| count | month |
+-------+----------+
| 505 | Apr-2010 |
| 252 | Mar-2010 |
| 426 | Feb-2010 |
| 201 | Jan-2010 |
| 211 | Dec-2009 |
+-------+----------+
text-processing awk
add a comment |
up vote
1
down vote
favorite
My input file is file1
count month
505 Apr-2010
252 Mar-2010
426 Feb-2010
201 Jan-2010
211 Dec-2009
Same file I want the output like this below
+-------+----------+
| count | month |
+-------+----------+
| 505 | Apr-2010 |
| 252 | Mar-2010 |
| 426 | Feb-2010 |
| 201 | Jan-2010 |
| 211 | Dec-2009 |
+-------+----------+
text-processing awk
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
My input file is file1
count month
505 Apr-2010
252 Mar-2010
426 Feb-2010
201 Jan-2010
211 Dec-2009
Same file I want the output like this below
+-------+----------+
| count | month |
+-------+----------+
| 505 | Apr-2010 |
| 252 | Mar-2010 |
| 426 | Feb-2010 |
| 201 | Jan-2010 |
| 211 | Dec-2009 |
+-------+----------+
text-processing awk
My input file is file1
count month
505 Apr-2010
252 Mar-2010
426 Feb-2010
201 Jan-2010
211 Dec-2009
Same file I want the output like this below
+-------+----------+
| count | month |
+-------+----------+
| 505 | Apr-2010 |
| 252 | Mar-2010 |
| 426 | Feb-2010 |
| 201 | Jan-2010 |
| 211 | Dec-2009 |
+-------+----------+
text-processing awk
text-processing awk
edited Nov 18 at 9:24
Rui F Ribeiro
38.2k1475123
38.2k1475123
asked Jul 21 '13 at 12:23
ganik
2315
2315
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
This will work for your input:
BEGIN
n=0
sep="+-------+----------+"
if (/^$/)
print sep
else if (n==0) "
else "$1"
n++
END
print sep
It doesn't do any automatic alignment so it will break if any of the fields increase in width. Take a look at this post for automatic alignment.
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
This will work for your input:
BEGIN
n=0
sep="+-------+----------+"
if (/^$/)
print sep
else if (n==0) "
else "$1"
n++
END
print sep
It doesn't do any automatic alignment so it will break if any of the fields increase in width. Take a look at this post for automatic alignment.
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
add a comment |
up vote
1
down vote
accepted
This will work for your input:
BEGIN
n=0
sep="+-------+----------+"
if (/^$/)
print sep
else if (n==0) "
else "$1"
n++
END
print sep
It doesn't do any automatic alignment so it will break if any of the fields increase in width. Take a look at this post for automatic alignment.
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
This will work for your input:
BEGIN
n=0
sep="+-------+----------+"
if (/^$/)
print sep
else if (n==0) "
else "$1"
n++
END
print sep
It doesn't do any automatic alignment so it will break if any of the fields increase in width. Take a look at this post for automatic alignment.
This will work for your input:
BEGIN
n=0
sep="+-------+----------+"
if (/^$/)
print sep
else if (n==0) "
else "$1"
n++
END
print sep
It doesn't do any automatic alignment so it will break if any of the fields increase in width. Take a look at this post for automatic alignment.
edited Apr 13 '17 at 12:22
Community♦
1
1
answered Jul 21 '13 at 12:47
Smith John
19.6k76273
19.6k76273
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
add a comment |
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
thnk u its working.. @Evan teitelman
– ganik
Jul 21 '13 at 13:47
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f83826%2fhow-to-design-the-table-in-awk%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown