awk - replace number greater than 17 digits in a column with -

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











up vote
2
down vote

favorite












I have a CSV file containing timestamp values in UTC which I need to replace with -. There may be more than one timestamp in the same column, can you please let me know how do I do that?



For example, this is one column in a CSV file:



+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0


The output should look like:



+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0









share|improve this question









New contributor




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



















  • Can you show an example of “more than one timestamp in the same column “?
    – Jeff Schaller
    1 hour ago






  • 1




    Re-reading your question, are you perhaps mixing up the terms row and column?
    – Jeff Schaller
    58 mins ago














up vote
2
down vote

favorite












I have a CSV file containing timestamp values in UTC which I need to replace with -. There may be more than one timestamp in the same column, can you please let me know how do I do that?



For example, this is one column in a CSV file:



+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0


The output should look like:



+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0









share|improve this question









New contributor




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



















  • Can you show an example of “more than one timestamp in the same column “?
    – Jeff Schaller
    1 hour ago






  • 1




    Re-reading your question, are you perhaps mixing up the terms row and column?
    – Jeff Schaller
    58 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have a CSV file containing timestamp values in UTC which I need to replace with -. There may be more than one timestamp in the same column, can you please let me know how do I do that?



For example, this is one column in a CSV file:



+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0


The output should look like:



+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0









share|improve this question









New contributor




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











I have a CSV file containing timestamp values in UTC which I need to replace with -. There may be more than one timestamp in the same column, can you please let me know how do I do that?



For example, this is one column in a CSV file:



+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0


The output should look like:



+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0






awk variable-substitution






share|improve this question









New contributor




Yashovan N 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




Yashovan N 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 1 hour ago









Patrick Mevzek

2,0581721




2,0581721






New contributor




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









asked 1 hour ago









Yashovan N

111




111




New contributor




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





New contributor





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






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











  • Can you show an example of “more than one timestamp in the same column “?
    – Jeff Schaller
    1 hour ago






  • 1




    Re-reading your question, are you perhaps mixing up the terms row and column?
    – Jeff Schaller
    58 mins ago
















  • Can you show an example of “more than one timestamp in the same column “?
    – Jeff Schaller
    1 hour ago






  • 1




    Re-reading your question, are you perhaps mixing up the terms row and column?
    – Jeff Schaller
    58 mins ago















Can you show an example of “more than one timestamp in the same column “?
– Jeff Schaller
1 hour ago




Can you show an example of “more than one timestamp in the same column “?
– Jeff Schaller
1 hour ago




1




1




Re-reading your question, are you perhaps mixing up the terms row and column?
– Jeff Schaller
58 mins ago




Re-reading your question, are you perhaps mixing up the terms row and column?
– Jeff Schaller
58 mins ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote













You can use awk as follows:



echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | awk 'gsub("[0-9]19", "-")1'
+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0


You can use sed as follows:



 echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | sed -r 's/[0-9]19/-/g'
+1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0





share|improve this answer






















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



    );






    Yashovan N is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472877%2fawk-replace-number-greater-than-17-digits-in-a-column-with%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
    5
    down vote













    You can use awk as follows:



    echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | awk 'gsub("[0-9]19", "-")1'
    +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0


    You can use sed as follows:



     echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | sed -r 's/[0-9]19/-/g'
    +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0





    share|improve this answer


























      up vote
      5
      down vote













      You can use awk as follows:



      echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | awk 'gsub("[0-9]19", "-")1'
      +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0


      You can use sed as follows:



       echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | sed -r 's/[0-9]19/-/g'
      +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0





      share|improve this answer
























        up vote
        5
        down vote










        up vote
        5
        down vote









        You can use awk as follows:



        echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | awk 'gsub("[0-9]19", "-")1'
        +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0


        You can use sed as follows:



         echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | sed -r 's/[0-9]19/-/g'
        +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0





        share|improve this answer














        You can use awk as follows:



        echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | awk 'gsub("[0-9]19", "-")1'
        +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0


        You can use sed as follows:



         echo "+1234|2|12|1|1|1537820114232192380|0 +1234|2|12|1|1|1537820113262689150|0" | sed -r 's/[0-9]19/-/g'
        +1234|2|12|1|1|-|0 +1234|2|12|1|1|-|0






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 38 mins ago

























        answered 43 mins ago









        Goro

        6,16552762




        6,16552762




















            Yashovan N is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Yashovan N is a new contributor. Be nice, and check out our Code of Conduct.












            Yashovan N is a new contributor. Be nice, and check out our Code of Conduct.











            Yashovan N is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472877%2fawk-replace-number-greater-than-17-digits-in-a-column-with%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery