Script using sed adds an “e” to the output filesProblem with script substitution when running scriptshell...
An Undercover Army
Has a sovereign Communist government ever run, and conceded loss, on a fair election?
Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?
Multi wire circuit or 2 separate 120V 20A dedicated circuits?
Generating a list with duplicate entries
Why is there an extra space when I type "ls" on the Desktop?
Why restrict private health insurance?
Draw this image in the TIKZ package
PTIJ: Sport in the Torah
What is the best index strategy or query SELECT when performing a search/lookup BETWEEN IP address (IPv4 and IPv6) ranges?
How do I align tablenotes in a threeparttable
How does a sound wave propagate?
Trigger on Custom Object Share
Create chunks from an array
Is there a math expression equivalent to the conditional ternary operator?
Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?
What does it take to become a wilderness skills guide as a business?
Having the player face themselves after the mid-game
What can I do if someone tampers with my SSH public key?
Can I negotiate a patent idea for a raise, under French law?
What is better: yes / no radio, or simple checkbox?
Why does a car's steering wheel get lighter with increasing speed
How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?
How to educate team mate to take screenshots for bugs with out unwanted stuff
Script using sed adds an “e” to the output files
Problem with script substitution when running scriptshell script, read is not waiting with sshscript convert files using dos2unixGet results from PHP pages after loginSudo execute command in PythonscriptProblem using sed to replace URLs in html files with scriptchange the DHCP lease table with script & sedSed bash script iterating multiple timesUnable to delete files using the scriptUsing sed to add characters at the end of a line adds a new line
I have a script that adds a new user and creates a virtual host for the users domain name. The script works great with one exception... in /etc/apache2/sites-available/ all of my virtual host files have two copies, one with an e and one without.
I believe my issue lies when I use the SED command. Can I get a second opinion?
Here is the script:
# set the working directory
dir=$(pwd)
# request the new domain name
printf "Enter the new domain name, without the www (i.e newdomain.com):n"
read newdomain
# request the new username
printf "Enter the new username (i.e newusername):n"
read username
# create the new user
sudo adduser $username
# copy the virtual host to sites-available
sudo cp /templates/domain-vhost /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully created the virtual host file at: /etc/apache2/sites-available/$newdomain.."
# change the domain name in the virtual host file
sudo sed -ie "s/NEWDOMAINNAME/$newdomain/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Modified the virtual host to reflect the new domain: $newdomain.."
# change the directory path in the virtual host
sudo sed -ie "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully modified the new virtual host file.."
# enable the site with apache
cd /etc/apache2/sites-available/
sudo a2ensite $newdomain
# echo results
echo "Successfully enabled the $newdomain.."
# change to previous working directory
cd $dir
# reload apache
sudo /etc/init.d/apache2 reload
# notify user of action
echo "Finished creating the new domain, $newdomain, and restarted Apache.."
scripts
add a comment |
I have a script that adds a new user and creates a virtual host for the users domain name. The script works great with one exception... in /etc/apache2/sites-available/ all of my virtual host files have two copies, one with an e and one without.
I believe my issue lies when I use the SED command. Can I get a second opinion?
Here is the script:
# set the working directory
dir=$(pwd)
# request the new domain name
printf "Enter the new domain name, without the www (i.e newdomain.com):n"
read newdomain
# request the new username
printf "Enter the new username (i.e newusername):n"
read username
# create the new user
sudo adduser $username
# copy the virtual host to sites-available
sudo cp /templates/domain-vhost /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully created the virtual host file at: /etc/apache2/sites-available/$newdomain.."
# change the domain name in the virtual host file
sudo sed -ie "s/NEWDOMAINNAME/$newdomain/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Modified the virtual host to reflect the new domain: $newdomain.."
# change the directory path in the virtual host
sudo sed -ie "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully modified the new virtual host file.."
# enable the site with apache
cd /etc/apache2/sites-available/
sudo a2ensite $newdomain
# echo results
echo "Successfully enabled the $newdomain.."
# change to previous working directory
cd $dir
# reload apache
sudo /etc/init.d/apache2 reload
# notify user of action
echo "Finished creating the new domain, $newdomain, and restarted Apache.."
scripts
3
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44
add a comment |
I have a script that adds a new user and creates a virtual host for the users domain name. The script works great with one exception... in /etc/apache2/sites-available/ all of my virtual host files have two copies, one with an e and one without.
I believe my issue lies when I use the SED command. Can I get a second opinion?
Here is the script:
# set the working directory
dir=$(pwd)
# request the new domain name
printf "Enter the new domain name, without the www (i.e newdomain.com):n"
read newdomain
# request the new username
printf "Enter the new username (i.e newusername):n"
read username
# create the new user
sudo adduser $username
# copy the virtual host to sites-available
sudo cp /templates/domain-vhost /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully created the virtual host file at: /etc/apache2/sites-available/$newdomain.."
# change the domain name in the virtual host file
sudo sed -ie "s/NEWDOMAINNAME/$newdomain/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Modified the virtual host to reflect the new domain: $newdomain.."
# change the directory path in the virtual host
sudo sed -ie "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully modified the new virtual host file.."
# enable the site with apache
cd /etc/apache2/sites-available/
sudo a2ensite $newdomain
# echo results
echo "Successfully enabled the $newdomain.."
# change to previous working directory
cd $dir
# reload apache
sudo /etc/init.d/apache2 reload
# notify user of action
echo "Finished creating the new domain, $newdomain, and restarted Apache.."
scripts
I have a script that adds a new user and creates a virtual host for the users domain name. The script works great with one exception... in /etc/apache2/sites-available/ all of my virtual host files have two copies, one with an e and one without.
I believe my issue lies when I use the SED command. Can I get a second opinion?
Here is the script:
# set the working directory
dir=$(pwd)
# request the new domain name
printf "Enter the new domain name, without the www (i.e newdomain.com):n"
read newdomain
# request the new username
printf "Enter the new username (i.e newusername):n"
read username
# create the new user
sudo adduser $username
# copy the virtual host to sites-available
sudo cp /templates/domain-vhost /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully created the virtual host file at: /etc/apache2/sites-available/$newdomain.."
# change the domain name in the virtual host file
sudo sed -ie "s/NEWDOMAINNAME/$newdomain/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Modified the virtual host to reflect the new domain: $newdomain.."
# change the directory path in the virtual host
sudo sed -ie "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
# echo results
echo "Successfully modified the new virtual host file.."
# enable the site with apache
cd /etc/apache2/sites-available/
sudo a2ensite $newdomain
# echo results
echo "Successfully enabled the $newdomain.."
# change to previous working directory
cd $dir
# reload apache
sudo /etc/init.d/apache2 reload
# notify user of action
echo "Finished creating the new domain, $newdomain, and restarted Apache.."
scripts
scripts
edited Jul 4 '11 at 20:25
Jorge Castro
36.8k106422617
36.8k106422617
asked Jul 4 '11 at 17:36
jason.dot.hjason.dot.h
13338
13338
3
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44
add a comment |
3
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44
3
3
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44
add a comment |
1 Answer
1
active
oldest
votes
You need separate -i and -e arguments to sed. -ie is telling sed to create a backup file with an 'e' appended.

To fix, just replace the sed invocation above to:
sudo sed -i -e "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f51775%2fscript-using-sed-adds-an-e-to-the-output-files%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
You need separate -i and -e arguments to sed. -ie is telling sed to create a backup file with an 'e' appended.

To fix, just replace the sed invocation above to:
sudo sed -i -e "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
add a comment |
You need separate -i and -e arguments to sed. -ie is telling sed to create a backup file with an 'e' appended.

To fix, just replace the sed invocation above to:
sudo sed -i -e "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
add a comment |
You need separate -i and -e arguments to sed. -ie is telling sed to create a backup file with an 'e' appended.

To fix, just replace the sed invocation above to:
sudo sed -i -e "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
You need separate -i and -e arguments to sed. -ie is telling sed to create a backup file with an 'e' appended.

To fix, just replace the sed invocation above to:
sudo sed -i -e "s/NEWUSERNAME/$username/" /etc/apache2/sites-available/$newdomain
edited 9 mins ago
Chris Schmitz
1054
1054
answered Jul 5 '11 at 2:39
Jeremy KerrJeremy Kerr
19.5k34058
19.5k34058
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
add a comment |
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
Although you've got a comment with this, I've adding the details as an answer for completeness.
– Jeremy Kerr
Jul 5 '11 at 2:40
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
When I first read this answer I understood what it was saying but didn't immediately grasp why the e was being taken as the suffix. I then checked the manual page and realized the i takes an optional argument. It makes this answer obvious in retrospect but it took me a second to understand the why (hence the image add).
– Chris Schmitz
2 hours ago
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f51775%2fscript-using-sed-adds-an-e-to-the-output-files%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
3
Sorry, after typing that I realized my mistake, when using the SED command I had the -i option to edit the file "inline" without creating the copy. For some reason I added the e command as well, which is supposed to add the script. I changed the -ie to -i and the script works as needed. I cannot answer my own question yet so I added a comment.
– jason.dot.h
Jul 4 '11 at 17:44