insert multiple lines to script with sedsed on OSX insert at a certain lineneed to replace a file contentssed...
what happens if i forgot to feed my sourdough starter?
Writing a clean implementation of Rock, Paper, Scissors game in c++
How to judge a Ph.D. applicant that arrives "out of thin air"
Is there anything wrong with Thrawn?
Character is called by their first initial. How do I write it?
How do I stop my characters falling in love?
The Sword in the Stone
kids pooling money for Lego League and taxes
Piece-drop Mate #2
Can the term divorcée apply if a woman has not only divorced, but subsequently remarried?
How to start an application when a specific disk is mounted
TSA asking to see cell phone
Will any serial mouse connect to Classic Macs?
Is it legal for private citizens to "impound" e-scooters?
Trying to build a function to compute divided difference for arbitrary list of points
How to deal with a player who makes bad characters and kills them?
Request for a Latin phrase as motto "God is highest/supreme"
Trapped in an ocean Temple in Minecraft?
Get delta of days by current hour and added delta of days
How to avoid unconsciously copying the style of my favorite writer?
What is the fate of sulfur in cysteine when it participates in gluconeogenesis?
Anybody know what this small Nintendo stand is for?
Spoken encryption
What is the lowest-speed bogey a jet fighter can intercept/escort?
insert multiple lines to script with sed
sed on OSX insert at a certain lineneed to replace a file contentssed append a text with many lines after matching of multiple strings while the text remains many lines in sed commandsed? - Insert line after a string with special characters to Neutron serviceHow to iterate a command with two different variables?Explain please sed scriptFixing a .csv file where some rows have missing columnsBash - How to access a variable with a number suffix using a FOR loopSED replaces space with new linesed not parsing t as a tab
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
i'm trying to insert variables before specific line in my script. this is the code that i'm using:
var1=$(echo "database1=")
var2=$(echo "database2=")
var3=$(echo "database3=")
sed -i "/#variables/i
$var1
$var2
$var3" /data1/create_database
i expect that create_database
be like this after i run above command:
database1=
database2=
database3=
#variables
but i get this result:
database1= database2= database3=
#variables
tried few ways nothing worked. what should i do?
bash shell-script centos sed
add a comment |
i'm trying to insert variables before specific line in my script. this is the code that i'm using:
var1=$(echo "database1=")
var2=$(echo "database2=")
var3=$(echo "database3=")
sed -i "/#variables/i
$var1
$var2
$var3" /data1/create_database
i expect that create_database
be like this after i run above command:
database1=
database2=
database3=
#variables
but i get this result:
database1= database2= database3=
#variables
tried few ways nothing worked. what should i do?
bash shell-script centos sed
add a comment |
i'm trying to insert variables before specific line in my script. this is the code that i'm using:
var1=$(echo "database1=")
var2=$(echo "database2=")
var3=$(echo "database3=")
sed -i "/#variables/i
$var1
$var2
$var3" /data1/create_database
i expect that create_database
be like this after i run above command:
database1=
database2=
database3=
#variables
but i get this result:
database1= database2= database3=
#variables
tried few ways nothing worked. what should i do?
bash shell-script centos sed
i'm trying to insert variables before specific line in my script. this is the code that i'm using:
var1=$(echo "database1=")
var2=$(echo "database2=")
var3=$(echo "database3=")
sed -i "/#variables/i
$var1
$var2
$var3" /data1/create_database
i expect that create_database
be like this after i run above command:
database1=
database2=
database3=
#variables
but i get this result:
database1= database2= database3=
#variables
tried few ways nothing worked. what should i do?
bash shell-script centos sed
bash shell-script centos sed
asked 31 mins ago
BlackCrystalBlackCrystal
3931 silver badge14 bronze badges
3931 silver badge14 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
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
});
}
});
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%2f532549%2finsert-multiple-lines-to-script-with-sed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f532549%2finsert-multiple-lines-to-script-with-sed%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