grep N lines after match

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am looking for a command where I can grep 20 or more lines after a specific match.



Example: grep "09:55:21,651" mylog_file.log



2018-02-26 09:55:21,651 ERROR [WebContainer : 0] (CommonAction.java:253) - SITAConnector Error: Empty SITA Response XML
com.ac.ccaswitch.exception.SitaConnectorException: Empty SITA Response XML
at com.ac.ccaswitch.connector.sita.SITAConnector.sendToSitaQueue(SITAConnector.java:144)
at com.ac.ccaswitch.entry.CommonAction.performTask(CommonAction.java:212)
at com.ac.ccaswitch.entry.PaymentServlet.doPost(PaymentServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:878)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:84)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)






share|improve this question






















  • sed or awk should be able to do this.
    – SabreWolfy
    Feb 27 at 5:33










  • you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
    – Sundeep
    Feb 27 at 5:58















up vote
1
down vote

favorite












I am looking for a command where I can grep 20 or more lines after a specific match.



Example: grep "09:55:21,651" mylog_file.log



2018-02-26 09:55:21,651 ERROR [WebContainer : 0] (CommonAction.java:253) - SITAConnector Error: Empty SITA Response XML
com.ac.ccaswitch.exception.SitaConnectorException: Empty SITA Response XML
at com.ac.ccaswitch.connector.sita.SITAConnector.sendToSitaQueue(SITAConnector.java:144)
at com.ac.ccaswitch.entry.CommonAction.performTask(CommonAction.java:212)
at com.ac.ccaswitch.entry.PaymentServlet.doPost(PaymentServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:878)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:84)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)






share|improve this question






















  • sed or awk should be able to do this.
    – SabreWolfy
    Feb 27 at 5:33










  • you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
    – Sundeep
    Feb 27 at 5:58













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am looking for a command where I can grep 20 or more lines after a specific match.



Example: grep "09:55:21,651" mylog_file.log



2018-02-26 09:55:21,651 ERROR [WebContainer : 0] (CommonAction.java:253) - SITAConnector Error: Empty SITA Response XML
com.ac.ccaswitch.exception.SitaConnectorException: Empty SITA Response XML
at com.ac.ccaswitch.connector.sita.SITAConnector.sendToSitaQueue(SITAConnector.java:144)
at com.ac.ccaswitch.entry.CommonAction.performTask(CommonAction.java:212)
at com.ac.ccaswitch.entry.PaymentServlet.doPost(PaymentServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:878)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:84)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)






share|improve this question














I am looking for a command where I can grep 20 or more lines after a specific match.



Example: grep "09:55:21,651" mylog_file.log



2018-02-26 09:55:21,651 ERROR [WebContainer : 0] (CommonAction.java:253) - SITAConnector Error: Empty SITA Response XML
com.ac.ccaswitch.exception.SitaConnectorException: Empty SITA Response XML
at com.ac.ccaswitch.connector.sita.SITAConnector.sendToSitaQueue(SITAConnector.java:144)
at com.ac.ccaswitch.entry.CommonAction.performTask(CommonAction.java:212)
at com.ac.ccaswitch.entry.PaymentServlet.doPost(PaymentServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1694)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:878)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:84)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)








share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 4:28









αғsнιη

14.9k82462




14.9k82462










asked Feb 27 at 4:05









Madhuraj

61




61











  • sed or awk should be able to do this.
    – SabreWolfy
    Feb 27 at 5:33










  • you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
    – Sundeep
    Feb 27 at 5:58

















  • sed or awk should be able to do this.
    – SabreWolfy
    Feb 27 at 5:33










  • you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
    – Sundeep
    Feb 27 at 5:58
















sed or awk should be able to do this.
– SabreWolfy
Feb 27 at 5:33




sed or awk should be able to do this.
– SabreWolfy
Feb 27 at 5:33












you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
– Sundeep
Feb 27 at 5:58





you can find the answer in this cross site duplicate ;) stackoverflow.com/questions/17908555/…
– Sundeep
Feb 27 at 5:58











1 Answer
1






active

oldest

votes

















up vote
3
down vote













you can use grep's -An switch to get n lines after the match so for your example that would be



grep -A20 "09:55:21,651" mylog_file.log



EDIT:
It looks like your version of grep does not support -A.
So here is a small script you can use instead



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
sed -n "$line,$(($line + $n - 1))p" < "$file"
done


you can use it like this: sh script.sh mylog_file.log "09:55:21,651" 20



EDIT2: While I am at it here is a solution that uses head and tail instead of sed just in case your sed is weird aswell



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
head "-$(($line + $n - 1))" "$file" | tail "-$n"
done





share|improve this answer






















  • This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
    – Madhuraj
    Feb 27 at 4:30











  • what version of grep are you using?
    – Captain Wobbles
    Feb 27 at 4:35










  • How to check the version of grep?
    – Madhuraj
    Feb 27 at 4:45










  • grep --version or grep -V
    – Captain Wobbles
    Feb 27 at 5:04






  • 1




    ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
    – Captain Wobbles
    Feb 27 at 5:20










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%2f426845%2fgrep-n-lines-after-match%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
3
down vote













you can use grep's -An switch to get n lines after the match so for your example that would be



grep -A20 "09:55:21,651" mylog_file.log



EDIT:
It looks like your version of grep does not support -A.
So here is a small script you can use instead



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
sed -n "$line,$(($line + $n - 1))p" < "$file"
done


you can use it like this: sh script.sh mylog_file.log "09:55:21,651" 20



EDIT2: While I am at it here is a solution that uses head and tail instead of sed just in case your sed is weird aswell



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
head "-$(($line + $n - 1))" "$file" | tail "-$n"
done





share|improve this answer






















  • This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
    – Madhuraj
    Feb 27 at 4:30











  • what version of grep are you using?
    – Captain Wobbles
    Feb 27 at 4:35










  • How to check the version of grep?
    – Madhuraj
    Feb 27 at 4:45










  • grep --version or grep -V
    – Captain Wobbles
    Feb 27 at 5:04






  • 1




    ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
    – Captain Wobbles
    Feb 27 at 5:20














up vote
3
down vote













you can use grep's -An switch to get n lines after the match so for your example that would be



grep -A20 "09:55:21,651" mylog_file.log



EDIT:
It looks like your version of grep does not support -A.
So here is a small script you can use instead



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
sed -n "$line,$(($line + $n - 1))p" < "$file"
done


you can use it like this: sh script.sh mylog_file.log "09:55:21,651" 20



EDIT2: While I am at it here is a solution that uses head and tail instead of sed just in case your sed is weird aswell



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
head "-$(($line + $n - 1))" "$file" | tail "-$n"
done





share|improve this answer






















  • This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
    – Madhuraj
    Feb 27 at 4:30











  • what version of grep are you using?
    – Captain Wobbles
    Feb 27 at 4:35










  • How to check the version of grep?
    – Madhuraj
    Feb 27 at 4:45










  • grep --version or grep -V
    – Captain Wobbles
    Feb 27 at 5:04






  • 1




    ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
    – Captain Wobbles
    Feb 27 at 5:20












up vote
3
down vote










up vote
3
down vote









you can use grep's -An switch to get n lines after the match so for your example that would be



grep -A20 "09:55:21,651" mylog_file.log



EDIT:
It looks like your version of grep does not support -A.
So here is a small script you can use instead



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
sed -n "$line,$(($line + $n - 1))p" < "$file"
done


you can use it like this: sh script.sh mylog_file.log "09:55:21,651" 20



EDIT2: While I am at it here is a solution that uses head and tail instead of sed just in case your sed is weird aswell



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
head "-$(($line + $n - 1))" "$file" | tail "-$n"
done





share|improve this answer














you can use grep's -An switch to get n lines after the match so for your example that would be



grep -A20 "09:55:21,651" mylog_file.log



EDIT:
It looks like your version of grep does not support -A.
So here is a small script you can use instead



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
sed -n "$line,$(($line + $n - 1))p" < "$file"
done


you can use it like this: sh script.sh mylog_file.log "09:55:21,651" 20



EDIT2: While I am at it here is a solution that uses head and tail instead of sed just in case your sed is weird aswell



#!/bin/sh
file="$1"
pattern="$2"
n="$3"
matches="$(grep -n $pattern $file)"
echo "$matches" | while read match; do
line="$match%%:*"
head "-$(($line + $n - 1))" "$file" | tail "-$n"
done






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 27 at 5:39

























answered Feb 27 at 4:09









Captain Wobbles

1565




1565











  • This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
    – Madhuraj
    Feb 27 at 4:30











  • what version of grep are you using?
    – Captain Wobbles
    Feb 27 at 4:35










  • How to check the version of grep?
    – Madhuraj
    Feb 27 at 4:45










  • grep --version or grep -V
    – Captain Wobbles
    Feb 27 at 5:04






  • 1




    ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
    – Captain Wobbles
    Feb 27 at 5:20
















  • This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
    – Madhuraj
    Feb 27 at 4:30











  • what version of grep are you using?
    – Captain Wobbles
    Feb 27 at 4:35










  • How to check the version of grep?
    – Madhuraj
    Feb 27 at 4:45










  • grep --version or grep -V
    – Captain Wobbles
    Feb 27 at 5:04






  • 1




    ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
    – Captain Wobbles
    Feb 27 at 5:20















This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
– Madhuraj
Feb 27 at 4:30





This is not working. I am getting this help content - abbcd@acsayul000012:/opt/logs$ grep -A 20 "09:55:21,651" CCASWITCH.log grep: illegal option -- A usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] pattern_list [file...] abbcd@acsayul000012:/opt/logs$
– Madhuraj
Feb 27 at 4:30













what version of grep are you using?
– Captain Wobbles
Feb 27 at 4:35




what version of grep are you using?
– Captain Wobbles
Feb 27 at 4:35












How to check the version of grep?
– Madhuraj
Feb 27 at 4:45




How to check the version of grep?
– Madhuraj
Feb 27 at 4:45












grep --version or grep -V
– Captain Wobbles
Feb 27 at 5:04




grep --version or grep -V
– Captain Wobbles
Feb 27 at 5:04




1




1




ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
– Captain Wobbles
Feb 27 at 5:20




ok from the error message i am guessing that you are running a solaris system. You can either install gnu grep which does support -A or try the script i edited in
– Captain Wobbles
Feb 27 at 5:20












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426845%2fgrep-n-lines-after-match%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay