Grep only a given number of lines after matchHow to show lines after each grep match until other specific...
What is the probability of a biased coin coming up heads given that a liar is claiming that the coin came up heads?
Repeated! Factorials!
Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday
What does the ISO setting for mechanical 35mm film cameras actually do?
What are the function of EM and EN spaces?
I was contacted by a private bank overseas to get my inheritance
London underground zone 1-2 train ticket
…down the primrose path
Why did the US Airways Flight 1549 passengers stay on the wings?
Non-small objects in categories
Which pronoun to replace an infinitive?
Is the first page of a novel really that important?
Did Captain America make out with his niece?
Ancients don't give a full level?
Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?
What prevents ads from reading my password as I type it?
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
Premier League simulation
Not been paid even after reminding the Treasurer; what should I do?
In MTG, was there ever a five-color deck that worked well?
If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?
The Game of the Century - why didn't Byrne take the rook after he forked Fischer?
Only charge capacitor when button pushed then turn on LED momentarily with capacitor when button released
Definitional equality of two propositions about propositional equality
Grep only a given number of lines after match
How to show lines after each grep match until other specific match?Exclude files that have very long lines of text from grep outputExtend grep to find a match after the first matchHow can I count the number of lines in a file after a grep match?Print n lines before match1 AND the lines after match1 until match2How to match a pattern in lines before another pattern matchAppend new lines to stream, until certain number is reachedCombine lines after grep -BHow to grep 7 lines after match and replace text?Grep doesn't work when trying to match a word from a file in a second file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I need to create a new file from a grep match but with maximum number of lines.
Something equivalent to this but one-liner
$ cat my_log_file.log | grep -v auto > filtered.log
$ tail -n 1000 filtered.log > filtered_1000_lines.log
linux grep
New contributor
add a comment |
I need to create a new file from a grep match but with maximum number of lines.
Something equivalent to this but one-liner
$ cat my_log_file.log | grep -v auto > filtered.log
$ tail -n 1000 filtered.log > filtered_1000_lines.log
linux grep
New contributor
Does your system's version ofgrep
support the-m NUM, --max-count=NUM
option?
– steeldriver
53 mins ago
@steeldriver it does, so the command isgrep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
1
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results ofgrep -v auto
. More clarity is needed on what you are trying to do.
– Nasir Riley
43 mins ago
add a comment |
I need to create a new file from a grep match but with maximum number of lines.
Something equivalent to this but one-liner
$ cat my_log_file.log | grep -v auto > filtered.log
$ tail -n 1000 filtered.log > filtered_1000_lines.log
linux grep
New contributor
I need to create a new file from a grep match but with maximum number of lines.
Something equivalent to this but one-liner
$ cat my_log_file.log | grep -v auto > filtered.log
$ tail -n 1000 filtered.log > filtered_1000_lines.log
linux grep
linux grep
New contributor
New contributor
edited 17 mins ago
Jeff Schaller♦
48.5k11 gold badges72 silver badges162 bronze badges
48.5k11 gold badges72 silver badges162 bronze badges
New contributor
asked 56 mins ago
Juan-KabbaliJuan-Kabbali
12 bronze badges
12 bronze badges
New contributor
New contributor
Does your system's version ofgrep
support the-m NUM, --max-count=NUM
option?
– steeldriver
53 mins ago
@steeldriver it does, so the command isgrep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
1
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results ofgrep -v auto
. More clarity is needed on what you are trying to do.
– Nasir Riley
43 mins ago
add a comment |
Does your system's version ofgrep
support the-m NUM, --max-count=NUM
option?
– steeldriver
53 mins ago
@steeldriver it does, so the command isgrep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
1
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results ofgrep -v auto
. More clarity is needed on what you are trying to do.
– Nasir Riley
43 mins ago
Does your system's version of
grep
support the -m NUM, --max-count=NUM
option?– steeldriver
53 mins ago
Does your system's version of
grep
support the -m NUM, --max-count=NUM
option?– steeldriver
53 mins ago
@steeldriver it does, so the command is
grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
@steeldriver it does, so the command is
grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
1
1
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of
grep -v auto
. More clarity is needed on what you are trying to do.– Nasir Riley
43 mins ago
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of
grep -v auto
. More clarity is needed on what you are trying to do.– Nasir Riley
43 mins ago
add a comment |
1 Answer
1
active
oldest
votes
The answer is
$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.
New contributor
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
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%2f534256%2fgrep-only-a-given-number-of-lines-after-match%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
The answer is
$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.
New contributor
add a comment |
The answer is
$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.
New contributor
add a comment |
The answer is
$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.
New contributor
The answer is
$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.
New contributor
New contributor
answered 37 mins ago
Juan-KabbaliJuan-Kabbali
12 bronze badges
12 bronze badges
New contributor
New contributor
add a comment |
add a comment |
Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f534256%2fgrep-only-a-given-number-of-lines-after-match%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
Does your system's version of
grep
support the-m NUM, --max-count=NUM
option?– steeldriver
53 mins ago
@steeldriver it does, so the command is
grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log
– Juan-Kabbali
43 mins ago
1
You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of
grep -v auto
. More clarity is needed on what you are trying to do.– Nasir Riley
43 mins ago