Isolate portion of line from log file, then print to screen

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












0















If I have a file that updates a record count every 5 minutes, the output looks something like this:



timestamp name of log file dataset record count 8600



timestamp name of log file dataset record count 8610



How can I effectively isolate dataset record count XXXX and print just that string to screen?










share|improve this question






















  • from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

    – Jeff Schaller
    Jan 17 at 16:47











  • Just that portion of the log file line. Not the entire line itself

    – GreNIX
    Jan 17 at 16:48











  • Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

    – Jeff Schaller
    Jan 17 at 16:52











  • Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

    – GreNIX
    Jan 17 at 16:53











  • Sorry, -o man page isn't confusing; -w is.

    – GreNIX
    Jan 17 at 16:56















0















If I have a file that updates a record count every 5 minutes, the output looks something like this:



timestamp name of log file dataset record count 8600



timestamp name of log file dataset record count 8610



How can I effectively isolate dataset record count XXXX and print just that string to screen?










share|improve this question






















  • from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

    – Jeff Schaller
    Jan 17 at 16:47











  • Just that portion of the log file line. Not the entire line itself

    – GreNIX
    Jan 17 at 16:48











  • Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

    – Jeff Schaller
    Jan 17 at 16:52











  • Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

    – GreNIX
    Jan 17 at 16:53











  • Sorry, -o man page isn't confusing; -w is.

    – GreNIX
    Jan 17 at 16:56













0












0








0








If I have a file that updates a record count every 5 minutes, the output looks something like this:



timestamp name of log file dataset record count 8600



timestamp name of log file dataset record count 8610



How can I effectively isolate dataset record count XXXX and print just that string to screen?










share|improve this question














If I have a file that updates a record count every 5 minutes, the output looks something like this:



timestamp name of log file dataset record count 8600



timestamp name of log file dataset record count 8610



How can I effectively isolate dataset record count XXXX and print just that string to screen?







grep






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 17 at 16:45









GreNIX GreNIX

597




597












  • from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

    – Jeff Schaller
    Jan 17 at 16:47











  • Just that portion of the log file line. Not the entire line itself

    – GreNIX
    Jan 17 at 16:48











  • Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

    – Jeff Schaller
    Jan 17 at 16:52











  • Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

    – GreNIX
    Jan 17 at 16:53











  • Sorry, -o man page isn't confusing; -w is.

    – GreNIX
    Jan 17 at 16:56

















  • from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

    – Jeff Schaller
    Jan 17 at 16:47











  • Just that portion of the log file line. Not the entire line itself

    – GreNIX
    Jan 17 at 16:48











  • Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

    – Jeff Schaller
    Jan 17 at 16:52











  • Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

    – GreNIX
    Jan 17 at 16:53











  • Sorry, -o man page isn't confusing; -w is.

    – GreNIX
    Jan 17 at 16:56
















from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

– Jeff Schaller
Jan 17 at 16:47





from a file, or from a command? Just that text dataset record count (etc) or only the matching (entire) lines?

– Jeff Schaller
Jan 17 at 16:47













Just that portion of the log file line. Not the entire line itself

– GreNIX
Jan 17 at 16:48





Just that portion of the log file line. Not the entire line itself

– GreNIX
Jan 17 at 16:48













Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

– Jeff Schaller
Jan 17 at 16:52





Are you using an Operating System whose grep supports the -o flag? (GNU/Linux systems, mainly)

– Jeff Schaller
Jan 17 at 16:52













Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

– GreNIX
Jan 17 at 16:53





Rhel 7. I've attempted using -o, but admittedly I'm confused by the man page entry for it and may not be using it properly. Seems a bit convoluted to me.

– GreNIX
Jan 17 at 16:53













Sorry, -o man page isn't confusing; -w is.

– GreNIX
Jan 17 at 16:56





Sorry, -o man page isn't confusing; -w is.

– GreNIX
Jan 17 at 16:56










1 Answer
1






active

oldest

votes


















2














One way, with awk:



awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) ' input


or piped via:



command | awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) '


Or with a grep that accepts -o:



grep -Eo 'dataset record count [[:digit:]]+' input


or piped:



command | grep -Eo 'dataset record count [[:digit:]]+'





share|improve this answer























  • I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

    – GreNIX
    Jan 17 at 17:05











  • I needed to add the + to the end of the bracket

    – GreNIX
    Jan 17 at 17:06










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495115%2fisolate-portion-of-line-from-log-file-then-print-to-screen%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









2














One way, with awk:



awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) ' input


or piped via:



command | awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) '


Or with a grep that accepts -o:



grep -Eo 'dataset record count [[:digit:]]+' input


or piped:



command | grep -Eo 'dataset record count [[:digit:]]+'





share|improve this answer























  • I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

    – GreNIX
    Jan 17 at 17:05











  • I needed to add the + to the end of the bracket

    – GreNIX
    Jan 17 at 17:06















2














One way, with awk:



awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) ' input


or piped via:



command | awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) '


Or with a grep that accepts -o:



grep -Eo 'dataset record count [[:digit:]]+' input


or piped:



command | grep -Eo 'dataset record count [[:digit:]]+'





share|improve this answer























  • I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

    – GreNIX
    Jan 17 at 17:05











  • I needed to add the + to the end of the bracket

    – GreNIX
    Jan 17 at 17:06













2












2








2







One way, with awk:



awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) ' input


or piped via:



command | awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) '


Or with a grep that accepts -o:



grep -Eo 'dataset record count [[:digit:]]+' input


or piped:



command | grep -Eo 'dataset record count [[:digit:]]+'





share|improve this answer













One way, with awk:



awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) ' input


or piped via:



command | awk 'match($0, "dataset record count [[:digit:]]+") print substr($0, RSTART, RLENGTH) '


Or with a grep that accepts -o:



grep -Eo 'dataset record count [[:digit:]]+' input


or piped:



command | grep -Eo 'dataset record count [[:digit:]]+'






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 17 at 16:55









Jeff SchallerJeff Schaller

40.8k1056129




40.8k1056129












  • I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

    – GreNIX
    Jan 17 at 17:05











  • I needed to add the + to the end of the bracket

    – GreNIX
    Jan 17 at 17:06

















  • I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

    – GreNIX
    Jan 17 at 17:05











  • I needed to add the + to the end of the bracket

    – GreNIX
    Jan 17 at 17:06
















I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

– GreNIX
Jan 17 at 17:05





I've tried grep -Eo 'dataset [a-z A-Z 0-9]' but I'm not sure why it isn't working.

– GreNIX
Jan 17 at 17:05













I needed to add the + to the end of the bracket

– GreNIX
Jan 17 at 17:06





I needed to add the + to the end of the bracket

– GreNIX
Jan 17 at 17:06

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495115%2fisolate-portion-of-line-from-log-file-then-print-to-screen%23new-answer', 'question_page');

);

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






Popular posts from this blog

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

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?