Insert word in the middle of text for every multiples of 4sed - remove the very last occurrence of a string...

Why would an IIS hosted site prompt for AD account credential if accessed through a hostname or IP, but not through servername?

Why did MS-DOS applications built using Turbo Pascal fail to start with a division by zero error on faster systems?

Why doesn't 'd /= d' throw a division by zero exception?

How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?

Why do all fields in a QFT transform like *irreducible* representations of some group?

How to respectfully refuse to assist co-workers with IT issues?

How can I unambiguously ask for a new user's "Display Name"?

Couple of slangs I've heard when watching anime

Examples of topos that are not ordinary spaces

Why do gliders have bungee cords in the control systems and what do they do? Are they on all control surfaces? What about ultralights?

Would it be possible to have a GMO that produces chocolate?

What does "set -x" do in a bash script?

Are modern clipless shoes and pedals that much better than toe clips and straps?

How would you identify when an object in a Lissajous orbit needs station keeping?

How do I request a longer than normal leave of absence period for my wedding?

Architectural feasibility of a tiered circular stone keep

What is the difference between "Grippe" and "Männergrippe"?

Why do banks “park” their money at the European Central Bank?

I don't have the theoretical background in my PhD topic. I can't justify getting the degree

How to estimate Scoville level of home-made pepper sauce??

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

Antonym of "billable"

Non-visual Computers - thoughts?

Is gzip atomic?



Insert word in the middle of text for every multiples of 4


sed - remove the very last occurrence of a string (a comma) in a file?how to insert backslash at the front of # symbol?How to add the content of a text file to the middle of another text filePrint text between two patterns not containing a particular wordExtract multiple instances of text between the same two lines of textsed code understanding for text processingInsert Newlines into serial stream before writing to text filesed: insert text after Nth character preceding/following a given stringHow can I use sed to insert some text after a multiline match?How to append a variable in a text file after a certain word?






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







-1















Text:



exampleexampleexampleexample 


Desired output:



exam$plee$xamp$leex$ampl$eexa$mpl$


I did this:



sed 's/[^*]/&$/4'


But it doesn't work, is there another way to do it?










share|improve this question






















  • 1





    answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

    – αғsнιη
    yesterday













  • Now it's work @αғsнιη thx 👍

    – IISomeOneII
    yesterday


















-1















Text:



exampleexampleexampleexample 


Desired output:



exam$plee$xamp$leex$ampl$eexa$mpl$


I did this:



sed 's/[^*]/&$/4'


But it doesn't work, is there another way to do it?










share|improve this question






















  • 1





    answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

    – αғsнιη
    yesterday













  • Now it's work @αғsнιη thx 👍

    – IISomeOneII
    yesterday














-1












-1








-1








Text:



exampleexampleexampleexample 


Desired output:



exam$plee$xamp$leex$ampl$eexa$mpl$


I did this:



sed 's/[^*]/&$/4'


But it doesn't work, is there another way to do it?










share|improve this question
















Text:



exampleexampleexampleexample 


Desired output:



exam$plee$xamp$leex$ampl$eexa$mpl$


I did this:



sed 's/[^*]/&$/4'


But it doesn't work, is there another way to do it?







sed






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







IISomeOneII

















asked yesterday









IISomeOneIIIISomeOneII

1321 silver badge13 bronze badges




1321 silver badge13 bronze badges











  • 1





    answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

    – αғsнιη
    yesterday













  • Now it's work @αғsнιη thx 👍

    – IISomeOneII
    yesterday














  • 1





    answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

    – αғsнιη
    yesterday













  • Now it's work @αғsнιη thx 👍

    – IISomeOneII
    yesterday








1




1





answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

– αғsнιη
yesterday







answer to now deleted question: echo 'something' | sed 's/.{'$(( ( RANDOM % MAX) +MIN ))'}/&$/g' (replace MAX with a max number and MIN with min number); no you cannot easily revert that back if the $ character was previously can find in your input else ... | sed 's/$//g'

– αғsнιη
yesterday















Now it's work @αғsнιη thx 👍

– IISomeOneII
yesterday





Now it's work @αғsнιη thx 👍

– IISomeOneII
yesterday










1 Answer
1






active

oldest

votes


















1















To insert $ globally after four characters:



$ echo "exampleexampleexampleexample" | sed 's/.{4}/&$/g'
exam$plee$xamp$leex$ampl$eexa$mple$


The . matches one character and .{4} matches four of them. The replacement part &$ consists of the matched pattern & (four characters) and $. Using the g flag, the pattern is replaced globally (every four characters).






share|improve this answer




























  • Thanks It's work @Freddy, could you explain it for me?

    – IISomeOneII
    yesterday











  • Okay, and if I want to revert back and delete that $? @Freddy

    – IISomeOneII
    yesterday








  • 1





    Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

    – Freddy
    yesterday














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%2f536764%2finsert-word-in-the-middle-of-text-for-every-multiples-of-4%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















To insert $ globally after four characters:



$ echo "exampleexampleexampleexample" | sed 's/.{4}/&$/g'
exam$plee$xamp$leex$ampl$eexa$mple$


The . matches one character and .{4} matches four of them. The replacement part &$ consists of the matched pattern & (four characters) and $. Using the g flag, the pattern is replaced globally (every four characters).






share|improve this answer




























  • Thanks It's work @Freddy, could you explain it for me?

    – IISomeOneII
    yesterday











  • Okay, and if I want to revert back and delete that $? @Freddy

    – IISomeOneII
    yesterday








  • 1





    Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

    – Freddy
    yesterday
















1















To insert $ globally after four characters:



$ echo "exampleexampleexampleexample" | sed 's/.{4}/&$/g'
exam$plee$xamp$leex$ampl$eexa$mple$


The . matches one character and .{4} matches four of them. The replacement part &$ consists of the matched pattern & (four characters) and $. Using the g flag, the pattern is replaced globally (every four characters).






share|improve this answer




























  • Thanks It's work @Freddy, could you explain it for me?

    – IISomeOneII
    yesterday











  • Okay, and if I want to revert back and delete that $? @Freddy

    – IISomeOneII
    yesterday








  • 1





    Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

    – Freddy
    yesterday














1














1










1









To insert $ globally after four characters:



$ echo "exampleexampleexampleexample" | sed 's/.{4}/&$/g'
exam$plee$xamp$leex$ampl$eexa$mple$


The . matches one character and .{4} matches four of them. The replacement part &$ consists of the matched pattern & (four characters) and $. Using the g flag, the pattern is replaced globally (every four characters).






share|improve this answer















To insert $ globally after four characters:



$ echo "exampleexampleexampleexample" | sed 's/.{4}/&$/g'
exam$plee$xamp$leex$ampl$eexa$mple$


The . matches one character and .{4} matches four of them. The replacement part &$ consists of the matched pattern & (four characters) and $. Using the g flag, the pattern is replaced globally (every four characters).







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









FreddyFreddy

6,6301 gold badge6 silver badges24 bronze badges




6,6301 gold badge6 silver badges24 bronze badges
















  • Thanks It's work @Freddy, could you explain it for me?

    – IISomeOneII
    yesterday











  • Okay, and if I want to revert back and delete that $? @Freddy

    – IISomeOneII
    yesterday








  • 1





    Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

    – Freddy
    yesterday



















  • Thanks It's work @Freddy, could you explain it for me?

    – IISomeOneII
    yesterday











  • Okay, and if I want to revert back and delete that $? @Freddy

    – IISomeOneII
    yesterday








  • 1





    Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

    – Freddy
    yesterday

















Thanks It's work @Freddy, could you explain it for me?

– IISomeOneII
yesterday





Thanks It's work @Freddy, could you explain it for me?

– IISomeOneII
yesterday













Okay, and if I want to revert back and delete that $? @Freddy

– IISomeOneII
yesterday







Okay, and if I want to revert back and delete that $? @Freddy

– IISomeOneII
yesterday






1




1





Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

– Freddy
yesterday





Reversed: echo 'exam$plee$xamp$leex$ampl$eexa$mple$' | sed 's/(.{4})$/1/g'

– Freddy
yesterday


















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%2f536764%2finsert-word-in-the-middle-of-text-for-every-multiples-of-4%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

Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...