grep help of HPC jobs

The name of the pictureThe name of the pictureThe name of the pictureClash 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







share|improve this question




















  • Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
    – Kusalananda
    Apr 3 at 15:26















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







share|improve this question




















  • Please, don't post images of text. It makes it very difficult to test whether solutions actually work.
    – Kusalananda
    Apr 3 at 15:26













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







share|improve this question












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









share|improve this question











share|improve this question




share|improve this question










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

















  • 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











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 '





share|improve this answer




















  • 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 If this solves your issue, please consider accepting the answer.
    – Kusalananda
    Apr 3 at 15:57










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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 '





share|improve this answer




















  • 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 If this solves your issue, please consider accepting the answer.
    – Kusalananda
    Apr 3 at 15:57














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 '





share|improve this answer




















  • 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 If this solves your issue, please consider accepting the answer.
    – Kusalananda
    Apr 3 at 15:57












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 '





share|improve this answer












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 '






share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 3 at 15:21









Kusalananda

102k13201317




102k13201317











  • 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 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










  • @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















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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)