Retrieve the first few lines from testing result with head -n
I am testing a python program and desire to retrieve its first two lines of results
$ python twoSum.py
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 151
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 194
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 247
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 192
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 206
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 171
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 170
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 190
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 132
DEBUG-MainProcess:31921-MainThread:140190102726464 j: 63
[8, 63]
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
Employ head
to tackle the text
$ python twoSum.py | head -n 1
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 259
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 235
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 133
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 274
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 265
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 257
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 280
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 134
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 138
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 145
DEBUG-MainProcess:31978-MainThread:140699277834048 j: 75
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
It does not work,
How could I retrieve the first few lines which I want to see.
bash python3
add a comment |
I am testing a python program and desire to retrieve its first two lines of results
$ python twoSum.py
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 151
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 194
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 247
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 192
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 206
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 171
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 170
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 190
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 132
DEBUG-MainProcess:31921-MainThread:140190102726464 j: 63
[8, 63]
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
Employ head
to tackle the text
$ python twoSum.py | head -n 1
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 259
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 235
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 133
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 274
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 265
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 257
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 280
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 134
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 138
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 145
DEBUG-MainProcess:31978-MainThread:140699277834048 j: 75
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
It does not work,
How could I retrieve the first few lines which I want to see.
bash python3
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago
add a comment |
I am testing a python program and desire to retrieve its first two lines of results
$ python twoSum.py
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 151
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 194
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 247
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 192
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 206
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 171
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 170
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 190
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 132
DEBUG-MainProcess:31921-MainThread:140190102726464 j: 63
[8, 63]
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
Employ head
to tackle the text
$ python twoSum.py | head -n 1
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 259
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 235
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 133
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 274
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 265
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 257
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 280
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 134
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 138
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 145
DEBUG-MainProcess:31978-MainThread:140699277834048 j: 75
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
It does not work,
How could I retrieve the first few lines which I want to see.
bash python3
I am testing a python program and desire to retrieve its first two lines of results
$ python twoSum.py
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 151
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 194
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 247
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 192
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 206
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 171
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 170
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 190
DEBUG-MainProcess:31921-MainThread:140190102726464 j: None
DEBUG-MainProcess:31921-MainThread:140190102726464 find: 132
DEBUG-MainProcess:31921-MainThread:140190102726464 j: 63
[8, 63]
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
Employ head
to tackle the text
$ python twoSum.py | head -n 1
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 259
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 235
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 133
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 274
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 265
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 257
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 280
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 134
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 138
DEBUG-MainProcess:31978-MainThread:140699277834048 j: None
DEBUG-MainProcess:31978-MainThread:140699277834048 find: 145
DEBUG-MainProcess:31978-MainThread:140699277834048 j: 75
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
It does not work,
How could I retrieve the first few lines which I want to see.
bash python3
bash python3
edited 29 mins ago
JawSaw
asked 34 mins ago
JawSawJawSaw
445314
445314
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago
add a comment |
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago
add a comment |
1 Answer
1
active
oldest
votes
Likely the DEBUG-
outputs are going to the standard error stream rather than the standard output stream - try
python twoSum.py 2>&1 | head -n 1
to redirect stderr
(file descriptor #2) to stdout
(file descriptor #1); or (bash shorthand)
python twoSum.py |& head -n 1
For further information see the related question Using grep with pipe and ampersand to filter errors from find.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2faskubuntu.com%2fquestions%2f1127410%2fretrieve-the-first-few-lines-from-testing-result-with-head-n%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Likely the DEBUG-
outputs are going to the standard error stream rather than the standard output stream - try
python twoSum.py 2>&1 | head -n 1
to redirect stderr
(file descriptor #2) to stdout
(file descriptor #1); or (bash shorthand)
python twoSum.py |& head -n 1
For further information see the related question Using grep with pipe and ampersand to filter errors from find.
add a comment |
Likely the DEBUG-
outputs are going to the standard error stream rather than the standard output stream - try
python twoSum.py 2>&1 | head -n 1
to redirect stderr
(file descriptor #2) to stdout
(file descriptor #1); or (bash shorthand)
python twoSum.py |& head -n 1
For further information see the related question Using grep with pipe and ampersand to filter errors from find.
add a comment |
Likely the DEBUG-
outputs are going to the standard error stream rather than the standard output stream - try
python twoSum.py 2>&1 | head -n 1
to redirect stderr
(file descriptor #2) to stdout
(file descriptor #1); or (bash shorthand)
python twoSum.py |& head -n 1
For further information see the related question Using grep with pipe and ampersand to filter errors from find.
Likely the DEBUG-
outputs are going to the standard error stream rather than the standard output stream - try
python twoSum.py 2>&1 | head -n 1
to redirect stderr
(file descriptor #2) to stdout
(file descriptor #1); or (bash shorthand)
python twoSum.py |& head -n 1
For further information see the related question Using grep with pipe and ampersand to filter errors from find.
answered 14 mins ago
steeldriversteeldriver
69.8k11114186
69.8k11114186
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2faskubuntu.com%2fquestions%2f1127410%2fretrieve-the-first-few-lines-from-testing-result-with-head-n%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
could you please transmit the comment to answer. @steeldriver
– JawSaw
18 mins ago