grep help of HPC jobs

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
let say, I have table in the imagewhich is basically "qstat" of HPC jobs:

I like to print out columns 2 and 6 which match NDS==1 and TSK==1
I am using command:
qstat -a |grep ' $4=="1" $5=="1" ' |awk 'print $2, $6'
It shows no output with no error message. What I am missing?
Thanks,
Akand
awk grep
add a comment |Â
up vote
0
down vote
favorite
let say, I have table in the imagewhich is basically "qstat" of HPC jobs:

I like to print out columns 2 and 6 which match NDS==1 and TSK==1
I am using command:
qstat -a |grep ' $4=="1" $5=="1" ' |awk 'print $2, $6'
It shows no output with no error message. What I am missing?
Thanks,
Akand
awk grep
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
let say, I have table in the imagewhich is basically "qstat" of HPC jobs:

I like to print out columns 2 and 6 which match NDS==1 and TSK==1
I am using command:
qstat -a |grep ' $4=="1" $5=="1" ' |awk 'print $2, $6'
It shows no output with no error message. What I am missing?
Thanks,
Akand
awk grep
let say, I have table in the imagewhich is basically "qstat" of HPC jobs:

I like to print out columns 2 and 6 which match NDS==1 and TSK==1
I am using command:
qstat -a |grep ' $4=="1" $5=="1" ' |awk 'print $2, $6'
It shows no output with no error message. What I am missing?
Thanks,
Akand
awk grep
asked Apr 3 at 15:11
Akand
426
426
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26
add a comment |Â
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You are confusing grep and awk slightly.
With grep ' $4=="1" $5=="1" ', grep would interpret $4=="1" $5=="1" as a regular expression. This expression would try to match a 4 occuring after the end of the line ($), which can never happen.
Instead:
qstat -a | awk '$4 == "1" && $5 == "1" print $2, $6 '
If you want the header as well:
qstat -a | awk 'NR == 1 || ($4 == "1" && $5 == "1") print $2, $6 '
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger theprintstatement for the header line as well (the first input line which hasNRequal to 1), so that you get the column names. This is what I meant by "if you want the header as well".
â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
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
You are confusing grep and awk slightly.
With grep ' $4=="1" $5=="1" ', grep would interpret $4=="1" $5=="1" as a regular expression. This expression would try to match a 4 occuring after the end of the line ($), which can never happen.
Instead:
qstat -a | awk '$4 == "1" && $5 == "1" print $2, $6 '
If you want the header as well:
qstat -a | awk 'NR == 1 || ($4 == "1" && $5 == "1") print $2, $6 '
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger theprintstatement for the header line as well (the first input line which hasNRequal to 1), so that you get the column names. This is what I meant by "if you want the header as well".
â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
add a comment |Â
up vote
1
down vote
accepted
You are confusing grep and awk slightly.
With grep ' $4=="1" $5=="1" ', grep would interpret $4=="1" $5=="1" as a regular expression. This expression would try to match a 4 occuring after the end of the line ($), which can never happen.
Instead:
qstat -a | awk '$4 == "1" && $5 == "1" print $2, $6 '
If you want the header as well:
qstat -a | awk 'NR == 1 || ($4 == "1" && $5 == "1") print $2, $6 '
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger theprintstatement for the header line as well (the first input line which hasNRequal to 1), so that you get the column names. This is what I meant by "if you want the header as well".
â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You are confusing grep and awk slightly.
With grep ' $4=="1" $5=="1" ', grep would interpret $4=="1" $5=="1" as a regular expression. This expression would try to match a 4 occuring after the end of the line ($), which can never happen.
Instead:
qstat -a | awk '$4 == "1" && $5 == "1" print $2, $6 '
If you want the header as well:
qstat -a | awk 'NR == 1 || ($4 == "1" && $5 == "1") print $2, $6 '
You are confusing grep and awk slightly.
With grep ' $4=="1" $5=="1" ', grep would interpret $4=="1" $5=="1" as a regular expression. This expression would try to match a 4 occuring after the end of the line ($), which can never happen.
Instead:
qstat -a | awk '$4 == "1" && $5 == "1" print $2, $6 '
If you want the header as well:
qstat -a | awk 'NR == 1 || ($4 == "1" && $5 == "1") print $2, $6 '
answered Apr 3 at 15:21
Kusalananda
102k13201317
102k13201317
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger theprintstatement for the header line as well (the first input line which hasNRequal to 1), so that you get the column names. This is what I meant by "if you want the header as well".
â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
add a comment |Â
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger theprintstatement for the header line as well (the first input line which hasNRequal to 1), so that you get the column names. This is what I meant by "if you want the header as well".
â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
Thanks. Why NR == 1 ?
â Akand
Apr 3 at 15:32
@Akand That would trigger the
print statement for the header line as well (the first input line which has NR equal to 1), so that you get the column names. This is what I meant by "if you want the header as well".â Kusalananda
Apr 3 at 15:34
@Akand That would trigger the
print statement for the header line as well (the first input line which has NR equal to 1), so that you get the column names. This is what I meant by "if you want the header as well".â Kusalananda
Apr 3 at 15:34
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
@Akand If this solves your issue, please consider accepting the answer.
â Kusalananda
Apr 3 at 15:57
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%2f435305%2fgrep-help-of-hpc-jobs%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
Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
â Kusalananda
Apr 3 at 15:26