unix command to replace anything between between two delimiter positionsGiven two directory trees, how can I find out which files differ?Merging two files by a single column in unixIs there a command to list all Unix group names?Unix command to search a line in a file and replace itChange csv file delimiter in unixUnix command to print a data between two matching patternsNeed to replace a character in unix fileUnix AWK command - multiple character as a single delimiterMatch Anything In Between Strings For Linux Grep CommandReplacing the pipe in the double quoted csv file with comma using awk command

Notepad++ - How to find multiple values on the same line in any permutation

Would this system work to purify water?

Which household object drew this pattern?

Earth rotation discrepancy

Does travel insurance for short flight delays exist?

What are some interesting features that are common cross-linguistically but don't exist in English?

Sun setting in East!

Why is less being run unnecessarily by git?

Why does The Ancient One think differently about Doctor Strange in Endgame than the film Doctor Strange?

Can a gem used as the material component for the Magic Jar spell also be used for the Imprisonment spell?

In the MCU, why does Mjölnir retain its enchantments after Ragnarok?

Is using a hyperlink to close a modal a poor design decision?

Efficiently pathfinding many flocking enemies around obstacles

Are there any music source codes for sound chips?

Confirming resignation after resignation letter ripped up

Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")

Defense against attacks using dictionaries

Church Booleans

Is "The life is beautiful" incorrect or just very non-idiomatic?

What brought these couples together?

Potential new partner angry about first collaboration - how to answer email to close up this encounter in a graceful manner

Can a PC's alignment be forcibly changed?

What does どうかと思う mean?

LeetCode: Pascal's Triangle C#



unix command to replace anything between between two delimiter positions


Given two directory trees, how can I find out which files differ?Merging two files by a single column in unixIs there a command to list all Unix group names?Unix command to search a line in a file and replace itChange csv file delimiter in unixUnix command to print a data between two matching patternsNeed to replace a character in unix fileUnix AWK command - multiple character as a single delimiterMatch Anything In Between Strings For Linux Grep CommandReplacing the pipe in the double quoted csv file with comma using awk command






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















Please help me with a unix command to replace anything between two delimiter positions.
For ex: I have multiple files with below header data and I want replace the data between * delimiters at 9th and 10th position




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190115*1237*^*00501*000320089*0*P*|~


My output should like this:




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190327*1237*^*00501*000320089*0*P*|~









share|improve this question


























  • You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

    – Gilles Quenot
    Mar 27 at 17:01


















-1















Please help me with a unix command to replace anything between two delimiter positions.
For ex: I have multiple files with below header data and I want replace the data between * delimiters at 9th and 10th position




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190115*1237*^*00501*000320089*0*P*|~


My output should like this:




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190327*1237*^*00501*000320089*0*P*|~









share|improve this question


























  • You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

    – Gilles Quenot
    Mar 27 at 17:01














-1












-1








-1








Please help me with a unix command to replace anything between two delimiter positions.
For ex: I have multiple files with below header data and I want replace the data between * delimiters at 9th and 10th position




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190115*1237*^*00501*000320089*0*P*|~


My output should like this:




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190327*1237*^*00501*000320089*0*P*|~









share|improve this question
















Please help me with a unix command to replace anything between two delimiter positions.
For ex: I have multiple files with below header data and I want replace the data between * delimiters at 9th and 10th position




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190115*1237*^*00501*000320089*0*P*|~


My output should like this:




ISA*00* *00* *ZZ*80881 *ZZ*TNC0022 *190327*1237*^*00501*000320089*0*P*|~






linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 16:43









ceving

11k4 gold badges62 silver badges108 bronze badges




11k4 gold badges62 silver badges108 bronze badges










asked Mar 27 at 16:39









kiran kiran

1




1















  • You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

    – Gilles Quenot
    Mar 27 at 17:01


















  • You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

    – Gilles Quenot
    Mar 27 at 17:01

















You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

– Gilles Quenot
Mar 27 at 17:01






You should provide some simpler sample input/output that you will elaborate for this very particular case. This way, it will be more accurate for others users when searching the same response and you will be able to transpose the logic to your needs.

– Gilles Quenot
Mar 27 at 17:01













1 Answer
1






active

oldest

votes


















-1















Try this:



perl -pe 's/^((?:[^*]**)9)([^*]+)(.*)/$1190327$3/'


The regexp searches for 9 occurences 9 of anything but not being a star [^*] followed by a star * and stores all in the first capture group. The second capture is at least one character not being a star [^*]+. And the third capture is the rest of the line.



A matching line gets replaced by the first part $1, your new value 190327 and the third part $3.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f55382373%2funix-command-to-replace-anything-between-between-two-delimiter-positions%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









    -1















    Try this:



    perl -pe 's/^((?:[^*]**)9)([^*]+)(.*)/$1190327$3/'


    The regexp searches for 9 occurences 9 of anything but not being a star [^*] followed by a star * and stores all in the first capture group. The second capture is at least one character not being a star [^*]+. And the third capture is the rest of the line.



    A matching line gets replaced by the first part $1, your new value 190327 and the third part $3.






    share|improve this answer





























      -1















      Try this:



      perl -pe 's/^((?:[^*]**)9)([^*]+)(.*)/$1190327$3/'


      The regexp searches for 9 occurences 9 of anything but not being a star [^*] followed by a star * and stores all in the first capture group. The second capture is at least one character not being a star [^*]+. And the third capture is the rest of the line.



      A matching line gets replaced by the first part $1, your new value 190327 and the third part $3.






      share|improve this answer



























        -1














        -1










        -1









        Try this:



        perl -pe 's/^((?:[^*]**)9)([^*]+)(.*)/$1190327$3/'


        The regexp searches for 9 occurences 9 of anything but not being a star [^*] followed by a star * and stores all in the first capture group. The second capture is at least one character not being a star [^*]+. And the third capture is the rest of the line.



        A matching line gets replaced by the first part $1, your new value 190327 and the third part $3.






        share|improve this answer













        Try this:



        perl -pe 's/^((?:[^*]**)9)([^*]+)(.*)/$1190327$3/'


        The regexp searches for 9 occurences 9 of anything but not being a star [^*] followed by a star * and stores all in the first capture group. The second capture is at least one character not being a star [^*]+. And the third capture is the rest of the line.



        A matching line gets replaced by the first part $1, your new value 190327 and the third part $3.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 17:01









        cevingceving

        11k4 gold badges62 silver badges108 bronze badges




        11k4 gold badges62 silver badges108 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f55382373%2funix-command-to-replace-anything-between-between-two-delimiter-positions%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

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴