grep nth position in a string and echo it [on hold]

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











up vote
-5
down vote

favorite












I have this string below:



out[000: ]<ISO9090-9999999902299>


I want to grep "022" in using a script and echo it out.










share|improve this question









New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Jeff Schaller, Rui F Ribeiro, JigglyNaga, thrig, Archemar yesterday


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
    – Jeff Schaller
    yesterday










  • The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
    – developer_
    yesterday






  • 1




    Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
    – Jeff Schaller
    yesterday














up vote
-5
down vote

favorite












I have this string below:



out[000: ]<ISO9090-9999999902299>


I want to grep "022" in using a script and echo it out.










share|improve this question









New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Jeff Schaller, Rui F Ribeiro, JigglyNaga, thrig, Archemar yesterday


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
    – Jeff Schaller
    yesterday










  • The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
    – developer_
    yesterday






  • 1




    Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
    – Jeff Schaller
    yesterday












up vote
-5
down vote

favorite









up vote
-5
down vote

favorite











I have this string below:



out[000: ]<ISO9090-9999999902299>


I want to grep "022" in using a script and echo it out.










share|improve this question









New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have this string below:



out[000: ]<ISO9090-9999999902299>


I want to grep "022" in using a script and echo it out.







linux grep






share|improve this question









New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

38.1k1475123




38.1k1475123






New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









developer_

61




61




New contributor




developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






developer_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by Jeff Schaller, Rui F Ribeiro, JigglyNaga, thrig, Archemar yesterday


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by Jeff Schaller, Rui F Ribeiro, JigglyNaga, thrig, Archemar yesterday


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
    – Jeff Schaller
    yesterday










  • The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
    – developer_
    yesterday






  • 1




    Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
    – Jeff Schaller
    yesterday












  • 4




    What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
    – Jeff Schaller
    yesterday










  • The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
    – developer_
    yesterday






  • 1




    Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
    – Jeff Schaller
    yesterday







4




4




What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
– Jeff Schaller
yesterday




What's important about 022? With that string , you could just echo 022 and be done. Is it 7+3 characters from the end? Some number+3 from the beginning? Or some number after a (dash or less-than or "ISO" or dash or a string of 9's or.....?)
– Jeff Schaller
yesterday












The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
– developer_
yesterday




The importance of 022 or position 17 to 19 in that iso standard are where issues are detected. that would give the error. in the example i gave 022 gives some issues to be resolved. if its grepped or sed or awk the i should echo rather than showing everything.
– developer_
yesterday




1




1




Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
– Jeff Schaller
yesterday




Then I think your question would be better described as "extract the characters in positions 17-19 from a string" and better yet it would say if the string is piped in as input or is in a variable or is entered by the user or passed as a parameter to your script.
– Jeff Schaller
yesterday










2 Answers
2






active

oldest

votes

















up vote
0
down vote













Insist on grep? Try



$ echo "out[000: ]<ISO9090-9999999902299>" | grep -Eo "ISO.13..." | grep -Eo "...$"
022





share|improve this answer




















  • why should i echo the string, why not grep from it just?
    – developer_
    19 hours ago










  • You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
    – RudiC
    18 hours ago










  • that is coming from a debug file called test.debug with that string.
    – developer_
    18 hours ago










  • grep can read files...
    – RudiC
    18 hours ago

















up vote
0
down vote













Perl:



echo "out[000: ]<ISO9090-9999999902299>" | perl -lne 'print substr($_,27,3)'


AWK:



echo "out[000: ]<ISO9090-9999999902299>" | awk 'print substr($0,28,3)'





share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Insist on grep? Try



    $ echo "out[000: ]<ISO9090-9999999902299>" | grep -Eo "ISO.13..." | grep -Eo "...$"
    022





    share|improve this answer




















    • why should i echo the string, why not grep from it just?
      – developer_
      19 hours ago










    • You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
      – RudiC
      18 hours ago










    • that is coming from a debug file called test.debug with that string.
      – developer_
      18 hours ago










    • grep can read files...
      – RudiC
      18 hours ago














    up vote
    0
    down vote













    Insist on grep? Try



    $ echo "out[000: ]<ISO9090-9999999902299>" | grep -Eo "ISO.13..." | grep -Eo "...$"
    022





    share|improve this answer




















    • why should i echo the string, why not grep from it just?
      – developer_
      19 hours ago










    • You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
      – RudiC
      18 hours ago










    • that is coming from a debug file called test.debug with that string.
      – developer_
      18 hours ago










    • grep can read files...
      – RudiC
      18 hours ago












    up vote
    0
    down vote










    up vote
    0
    down vote









    Insist on grep? Try



    $ echo "out[000: ]<ISO9090-9999999902299>" | grep -Eo "ISO.13..." | grep -Eo "...$"
    022





    share|improve this answer












    Insist on grep? Try



    $ echo "out[000: ]<ISO9090-9999999902299>" | grep -Eo "ISO.13..." | grep -Eo "...$"
    022






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered yesterday









    RudiC

    2,9561211




    2,9561211











    • why should i echo the string, why not grep from it just?
      – developer_
      19 hours ago










    • You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
      – RudiC
      18 hours ago










    • that is coming from a debug file called test.debug with that string.
      – developer_
      18 hours ago










    • grep can read files...
      – RudiC
      18 hours ago
















    • why should i echo the string, why not grep from it just?
      – developer_
      19 hours ago










    • You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
      – RudiC
      18 hours ago










    • that is coming from a debug file called test.debug with that string.
      – developer_
      18 hours ago










    • grep can read files...
      – RudiC
      18 hours ago















    why should i echo the string, why not grep from it just?
    – developer_
    19 hours ago




    why should i echo the string, why not grep from it just?
    – developer_
    19 hours ago












    You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
    – RudiC
    18 hours ago




    You didn't specify how and where that string is stored / comes from. "String" usually refers to a (shell?) variable that grep can't deal with immediately. If it is printed from some program / command, pipe it into the greps.
    – RudiC
    18 hours ago












    that is coming from a debug file called test.debug with that string.
    – developer_
    18 hours ago




    that is coming from a debug file called test.debug with that string.
    – developer_
    18 hours ago












    grep can read files...
    – RudiC
    18 hours ago




    grep can read files...
    – RudiC
    18 hours ago












    up vote
    0
    down vote













    Perl:



    echo "out[000: ]<ISO9090-9999999902299>" | perl -lne 'print substr($_,27,3)'


    AWK:



    echo "out[000: ]<ISO9090-9999999902299>" | awk 'print substr($0,28,3)'





    share|improve this answer
























      up vote
      0
      down vote













      Perl:



      echo "out[000: ]<ISO9090-9999999902299>" | perl -lne 'print substr($_,27,3)'


      AWK:



      echo "out[000: ]<ISO9090-9999999902299>" | awk 'print substr($0,28,3)'





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Perl:



        echo "out[000: ]<ISO9090-9999999902299>" | perl -lne 'print substr($_,27,3)'


        AWK:



        echo "out[000: ]<ISO9090-9999999902299>" | awk 'print substr($0,28,3)'





        share|improve this answer












        Perl:



        echo "out[000: ]<ISO9090-9999999902299>" | perl -lne 'print substr($_,27,3)'


        AWK:



        echo "out[000: ]<ISO9090-9999999902299>" | awk 'print substr($0,28,3)'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        simlev

        6032214




        6032214












            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?