awk if command that works to print column 19 only but how would i get it to print both columns?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I want to print column 3 and 4 but without printing the headers empty column lines.
header
tap
norm
X Y 880 1787
X Y 3253 3439
Printing this via awk 'print($3,$4)'
gives
(BLANK lines from header rows)
880 1787
3253 3439
This works to print column 19 only but how would I get it to print both columns?
awk '$3print $3'
880
3253
I want col3 col4
880 1787
3253 3439
I tried but get only column 3 printed
awk '$3print $3''$4print $4'
880
1787
3253
3439
awk
add a comment |Â
up vote
0
down vote
favorite
I want to print column 3 and 4 but without printing the headers empty column lines.
header
tap
norm
X Y 880 1787
X Y 3253 3439
Printing this via awk 'print($3,$4)'
gives
(BLANK lines from header rows)
880 1787
3253 3439
This works to print column 19 only but how would I get it to print both columns?
awk '$3print $3'
880
3253
I want col3 col4
880 1787
3253 3439
I tried but get only column 3 printed
awk '$3print $3''$4print $4'
880
1787
3253
3439
awk
1
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then theman
page forawk
or google will help you. You're on the right track.
â Nasir Riley
Apr 10 at 1:26
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to print column 3 and 4 but without printing the headers empty column lines.
header
tap
norm
X Y 880 1787
X Y 3253 3439
Printing this via awk 'print($3,$4)'
gives
(BLANK lines from header rows)
880 1787
3253 3439
This works to print column 19 only but how would I get it to print both columns?
awk '$3print $3'
880
3253
I want col3 col4
880 1787
3253 3439
I tried but get only column 3 printed
awk '$3print $3''$4print $4'
880
1787
3253
3439
awk
I want to print column 3 and 4 but without printing the headers empty column lines.
header
tap
norm
X Y 880 1787
X Y 3253 3439
Printing this via awk 'print($3,$4)'
gives
(BLANK lines from header rows)
880 1787
3253 3439
This works to print column 19 only but how would I get it to print both columns?
awk '$3print $3'
880
3253
I want col3 col4
880 1787
3253 3439
I tried but get only column 3 printed
awk '$3print $3''$4print $4'
880
1787
3253
3439
awk
edited Apr 10 at 6:07
Filipe Brandenburger
3,451621
3,451621
asked Apr 10 at 0:10
Dominique
33
33
1
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then theman
page forawk
or google will help you. You're on the right track.
â Nasir Riley
Apr 10 at 1:26
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47
add a comment |Â
1
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then theman
page forawk
or google will help you. You're on the right track.
â Nasir Riley
Apr 10 at 1:26
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47
1
1
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the
man
page for awk
or google will help you. You're on the right track.â Nasir Riley
Apr 10 at 1:26
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the
man
page for awk
or google will help you. You're on the right track.â Nasir Riley
Apr 10 at 1:26
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You know how long the head is (three lines):
awk 'NR > 3 print $3, $4 '
NR
is the number of records (lines by default) that has been read so far. With NR > 3
we trigger the print
statement for the fourth line and all lines after.
You could use
awk '$3 print $3, $4 '
but this is a bit fragile as it depends on not only $3
being present but also that it is non-zero (a zero in the third column would give no output for that line).
add a comment |Â
up vote
0
down vote
If
header
tap
norm
X Y 880 1787
X Y 3253 3439
Then
awk 'print $3 " " $4' | sed '/^ *$/d'
Makes
880 1787
3253 3439
And for your last part you can try
awk 'print $3 " " $4 " " $19'
To print the 3rd, 4th and 19th columns.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You know how long the head is (three lines):
awk 'NR > 3 print $3, $4 '
NR
is the number of records (lines by default) that has been read so far. With NR > 3
we trigger the print
statement for the fourth line and all lines after.
You could use
awk '$3 print $3, $4 '
but this is a bit fragile as it depends on not only $3
being present but also that it is non-zero (a zero in the third column would give no output for that line).
add a comment |Â
up vote
1
down vote
accepted
You know how long the head is (three lines):
awk 'NR > 3 print $3, $4 '
NR
is the number of records (lines by default) that has been read so far. With NR > 3
we trigger the print
statement for the fourth line and all lines after.
You could use
awk '$3 print $3, $4 '
but this is a bit fragile as it depends on not only $3
being present but also that it is non-zero (a zero in the third column would give no output for that line).
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You know how long the head is (three lines):
awk 'NR > 3 print $3, $4 '
NR
is the number of records (lines by default) that has been read so far. With NR > 3
we trigger the print
statement for the fourth line and all lines after.
You could use
awk '$3 print $3, $4 '
but this is a bit fragile as it depends on not only $3
being present but also that it is non-zero (a zero in the third column would give no output for that line).
You know how long the head is (three lines):
awk 'NR > 3 print $3, $4 '
NR
is the number of records (lines by default) that has been read so far. With NR > 3
we trigger the print
statement for the fourth line and all lines after.
You could use
awk '$3 print $3, $4 '
but this is a bit fragile as it depends on not only $3
being present but also that it is non-zero (a zero in the third column would give no output for that line).
answered Apr 10 at 6:36
Kusalananda
102k13200317
102k13200317
add a comment |Â
add a comment |Â
up vote
0
down vote
If
header
tap
norm
X Y 880 1787
X Y 3253 3439
Then
awk 'print $3 " " $4' | sed '/^ *$/d'
Makes
880 1787
3253 3439
And for your last part you can try
awk 'print $3 " " $4 " " $19'
To print the 3rd, 4th and 19th columns.
add a comment |Â
up vote
0
down vote
If
header
tap
norm
X Y 880 1787
X Y 3253 3439
Then
awk 'print $3 " " $4' | sed '/^ *$/d'
Makes
880 1787
3253 3439
And for your last part you can try
awk 'print $3 " " $4 " " $19'
To print the 3rd, 4th and 19th columns.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If
header
tap
norm
X Y 880 1787
X Y 3253 3439
Then
awk 'print $3 " " $4' | sed '/^ *$/d'
Makes
880 1787
3253 3439
And for your last part you can try
awk 'print $3 " " $4 " " $19'
To print the 3rd, 4th and 19th columns.
If
header
tap
norm
X Y 880 1787
X Y 3253 3439
Then
awk 'print $3 " " $4' | sed '/^ *$/d'
Makes
880 1787
3253 3439
And for your last part you can try
awk 'print $3 " " $4 " " $19'
To print the 3rd, 4th and 19th columns.
edited Apr 10 at 6:35
answered Apr 10 at 5:15
CubeSyVal
85
85
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436651%2fawk-if-command-that-works-to-print-column-19-only-but-how-would-i-get-it-to-prin%23new-answer', 'question_page');
);
Post as a guest
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
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
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
1
It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the
man
page forawk
or google will help you. You're on the right track.â Nasir Riley
Apr 10 at 1:26
Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
â muru
Apr 10 at 4:47