How do add complex text using vim/sed/awkHow to insert the content of a file into another file before a...
How can I perform a deterministic physics simulation?
In MTG, was there ever a five-color deck that worked well?
Upper Bound for a Sum
What license to choose for my PhD thesis?
…down the primrose path
What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?
What are the limitations of the Hendersson-Hasselbalch equation?
I was contacted by a private bank overseas to get my inheritance
How do I show and not tell a backstory?
Why do rocket engines use nitrogen actuators to operate the fuel/oxidiser valves instead of electric servos?
Why does capacitance not depend on the material of the plates?
How does Rust's 128-bit integer `i128` work on a 64-bit system?
How do people drown while wearing a life jacket?
What printing process is this?
Repeated! Factorials!
Getting an entry level IT position later in life
Getting Lost in the Caves of Chaos
What is the reason behind water not falling from a bucket at the top of loop?
foot-pounds of energy?
Why wasn't interlaced CRT scanning done back and forth?
Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?
GFCI tripping on overload?
What could prevent players from leaving an island?
Four-velocity of radially infalling gas in Schwarzschild metric
How do add complex text using vim/sed/awk
How to insert the content of a file into another file before a pattern (marker)?How do I use vim on the command line to add text to the middle of a file?Inserting a file into another file after the 1st occurrence of a patternHow to match two lines at once in vimHow to add time stamp(month_year) to the file after matching specific string?how to understand n in vimAppending a character in the nth position of a matching stringsed match the 2nd occurrence of the patternHow to read lines from a file and combine before a pattern match from another file?Stop vim pasting selections as text!Using middle mouse click to paste text enters insert modeHow to insert text after a certain string in a file (on OSX)?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
following older posts (How do I use vim on the command line to add text to the middle of a file? & How to insert the content of a file into another file before a pattern (marker)?), I have a more complex case which I need your advice.
I have the following Test.conf file:
server {
listen 80;
server_name jenkins2;
location /DE06/ {
proxy_pass http://jenkins2:18015/DE06/;
}
}
I want to run one command, so in the end, the file content will be:
server {
listen 80;
server_name jenkins2;
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
location /DE06/ {
proxy_pass http://jenkins2:52716/DE06/;
}
}
means I need to find the first occurrence of the word jenkins2, and then add this content:
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
any idea what is the right command?
linux text-processing awk sed vim
New contributor
add a comment |
following older posts (How do I use vim on the command line to add text to the middle of a file? & How to insert the content of a file into another file before a pattern (marker)?), I have a more complex case which I need your advice.
I have the following Test.conf file:
server {
listen 80;
server_name jenkins2;
location /DE06/ {
proxy_pass http://jenkins2:18015/DE06/;
}
}
I want to run one command, so in the end, the file content will be:
server {
listen 80;
server_name jenkins2;
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
location /DE06/ {
proxy_pass http://jenkins2:52716/DE06/;
}
}
means I need to find the first occurrence of the word jenkins2, and then add this content:
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
any idea what is the right command?
linux text-processing awk sed vim
New contributor
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
1
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago
add a comment |
following older posts (How do I use vim on the command line to add text to the middle of a file? & How to insert the content of a file into another file before a pattern (marker)?), I have a more complex case which I need your advice.
I have the following Test.conf file:
server {
listen 80;
server_name jenkins2;
location /DE06/ {
proxy_pass http://jenkins2:18015/DE06/;
}
}
I want to run one command, so in the end, the file content will be:
server {
listen 80;
server_name jenkins2;
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
location /DE06/ {
proxy_pass http://jenkins2:52716/DE06/;
}
}
means I need to find the first occurrence of the word jenkins2, and then add this content:
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
any idea what is the right command?
linux text-processing awk sed vim
New contributor
following older posts (How do I use vim on the command line to add text to the middle of a file? & How to insert the content of a file into another file before a pattern (marker)?), I have a more complex case which I need your advice.
I have the following Test.conf file:
server {
listen 80;
server_name jenkins2;
location /DE06/ {
proxy_pass http://jenkins2:18015/DE06/;
}
}
I want to run one command, so in the end, the file content will be:
server {
listen 80;
server_name jenkins2;
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
location /DE06/ {
proxy_pass http://jenkins2:52716/DE06/;
}
}
means I need to find the first occurrence of the word jenkins2, and then add this content:
location /DE15/ {
proxy_pass http://jenkins2:18015/DE15/;
}
any idea what is the right command?
linux text-processing awk sed vim
linux text-processing awk sed vim
New contributor
New contributor
edited 2 hours ago
arielma
32 bronze badges
32 bronze badges
New contributor
asked 15 hours ago
ArielAriel
11 bronze badge
11 bronze badge
New contributor
New contributor
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
1
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago
add a comment |
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
1
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
1
1
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago
add a comment |
1 Answer
1
active
oldest
votes
vim +/jenkins2 +j +":r insert.txt" +gg=G +wq testfile.txt
where insert.txt contains the snippet you want to add and testfile.txt is the file you want do edit.
I'm not sure vim is the best tool to do that, though.
+/jenkins2
search for jenkins2
+j
move down one line
":r insert.txt"
read the file to insert. Mind the quotes!
+gg=G
autoindent the file
+wq
and write it
New contributor
add a comment |
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
});
}
});
Ariel is a new contributor. Be nice, and check out our Code of Conduct.
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%2funix.stackexchange.com%2fquestions%2f533954%2fhow-do-add-complex-text-using-vim-sed-awk%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
vim +/jenkins2 +j +":r insert.txt" +gg=G +wq testfile.txt
where insert.txt contains the snippet you want to add and testfile.txt is the file you want do edit.
I'm not sure vim is the best tool to do that, though.
+/jenkins2
search for jenkins2
+j
move down one line
":r insert.txt"
read the file to insert. Mind the quotes!
+gg=G
autoindent the file
+wq
and write it
New contributor
add a comment |
vim +/jenkins2 +j +":r insert.txt" +gg=G +wq testfile.txt
where insert.txt contains the snippet you want to add and testfile.txt is the file you want do edit.
I'm not sure vim is the best tool to do that, though.
+/jenkins2
search for jenkins2
+j
move down one line
":r insert.txt"
read the file to insert. Mind the quotes!
+gg=G
autoindent the file
+wq
and write it
New contributor
add a comment |
vim +/jenkins2 +j +":r insert.txt" +gg=G +wq testfile.txt
where insert.txt contains the snippet you want to add and testfile.txt is the file you want do edit.
I'm not sure vim is the best tool to do that, though.
+/jenkins2
search for jenkins2
+j
move down one line
":r insert.txt"
read the file to insert. Mind the quotes!
+gg=G
autoindent the file
+wq
and write it
New contributor
vim +/jenkins2 +j +":r insert.txt" +gg=G +wq testfile.txt
where insert.txt contains the snippet you want to add and testfile.txt is the file you want do edit.
I'm not sure vim is the best tool to do that, though.
+/jenkins2
search for jenkins2
+j
move down one line
":r insert.txt"
read the file to insert. Mind the quotes!
+gg=G
autoindent the file
+wq
and write it
New contributor
edited 14 hours ago
New contributor
answered 14 hours ago
markgrafmarkgraf
1204 bronze badges
1204 bronze badges
New contributor
New contributor
add a comment |
add a comment |
Ariel is a new contributor. Be nice, and check out our Code of Conduct.
Ariel is a new contributor. Be nice, and check out our Code of Conduct.
Ariel is a new contributor. Be nice, and check out our Code of Conduct.
Ariel is a new contributor. Be nice, and check out our Code of Conduct.
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.
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%2funix.stackexchange.com%2fquestions%2f533954%2fhow-do-add-complex-text-using-vim-sed-awk%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
This would be better asked in Vi and Vim Stack Exchange.
– Ray Butterworth
14 hours ago
1
Does the answer have to use vim? While it's an editor, there are other ways of updating files programmatically.
– Jeff Schaller♦
12 hours ago