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;
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
add a comment |
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
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
add a comment |
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
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
linux
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 27 at 17:01
cevingceving
11k4 gold badges62 silver badges108 bronze badges
11k4 gold badges62 silver badges108 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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