new line not append instead append on the end of the line2019 Community Moderator ElectionHow to add a newline to the end of a file?awk not doing a new lineTransferring a variable from one file to anotherVar1 is set to contents of command executed, how to set Var2 to be the command from Var1How to pass multiple arguments through ssh and use those arguments in the ssh script?In bash, how to delay interpolation of a variable that has a dynamic variable within its stringHow to iterate a command with two different variables?Add (prepend) line to file, if parameter is not already existingappend text with echo without new lineBash - How to access a variable with a number suffix using a FOR loopShell script to create one file and append the results
How to preserve electronics (computers, iPads and phones) for hundreds of years
How do I fix the group tension caused by my character stealing and possibly killing without provocation?
El Dorado Word Puzzle II: Videogame Edition
Does Doodling or Improvising on the Piano Have Any Benefits?
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Sigmoid with a slope but no asymptotes?
How do you justify more code being written by following clean code practices?
How many people need to be born every 8 years to sustain population?
Deciphering cause of death?
Make a Bowl of Alphabet Soup
Isometric embedding of a genus g surface
The Digit Triangles
How do I Interface a PS/2 Keyboard without Modern Techniques?
Can I say "fingers" when referring to toes?
Would this string work as string?
What is the smallest number n> 5 so that 5 ^ n ends with "3125"?
What happens if I try to grapple an illusory duplicate from the Mirror Image spell?
Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?
Why does the Persian emissary display a string of crowned skulls?
Air travel with refrigerated insulin
Should I assume I have passed probation?
Should I warn new/prospective PhD Student that supervisor is terrible?
Why didn’t Eve recognize the little cockroach as a living organism?
Ways of geometrical multiplication
new line not append instead append on the end of the line
2019 Community Moderator ElectionHow to add a newline to the end of a file?awk not doing a new lineTransferring a variable from one file to anotherVar1 is set to contents of command executed, how to set Var2 to be the command from Var1How to pass multiple arguments through ssh and use those arguments in the ssh script?In bash, how to delay interpolation of a variable that has a dynamic variable within its stringHow to iterate a command with two different variables?Add (prepend) line to file, if parameter is not already existingappend text with echo without new lineBash - How to access a variable with a number suffix using a FOR loopShell script to create one file and append the results
we gave the following config file ( config.txt )
more config.txt
export var1=345476746
but when I am appending new parameter as
echo "export var2=5645" >> config.txt
we get
more config.txt
export var1=345476746export var2=5645
how to avoid this?
so we get
more config.txt
export var1=345476746
export var2=5645
linux bash shell-script shell
add a comment |
we gave the following config file ( config.txt )
more config.txt
export var1=345476746
but when I am appending new parameter as
echo "export var2=5645" >> config.txt
we get
more config.txt
export var1=345476746export var2=5645
how to avoid this?
so we get
more config.txt
export var1=345476746
export var2=5645
linux bash shell-script shell
2
config.txt
has no newline at the end of the file. Fix that or simply add one before addingvar2
.
– RoVo
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. Invim
, files withoutn
in the last line is indicated in the status line by[noeol]
.
– Weijun Zhou
19 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago
add a comment |
we gave the following config file ( config.txt )
more config.txt
export var1=345476746
but when I am appending new parameter as
echo "export var2=5645" >> config.txt
we get
more config.txt
export var1=345476746export var2=5645
how to avoid this?
so we get
more config.txt
export var1=345476746
export var2=5645
linux bash shell-script shell
we gave the following config file ( config.txt )
more config.txt
export var1=345476746
but when I am appending new parameter as
echo "export var2=5645" >> config.txt
we get
more config.txt
export var1=345476746export var2=5645
how to avoid this?
so we get
more config.txt
export var1=345476746
export var2=5645
linux bash shell-script shell
linux bash shell-script shell
asked 19 hours ago
yaelyael
2,73422575
2,73422575
2
config.txt
has no newline at the end of the file. Fix that or simply add one before addingvar2
.
– RoVo
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. Invim
, files withoutn
in the last line is indicated in the status line by[noeol]
.
– Weijun Zhou
19 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago
add a comment |
2
config.txt
has no newline at the end of the file. Fix that or simply add one before addingvar2
.
– RoVo
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. Invim
, files withoutn
in the last line is indicated in the status line by[noeol]
.
– Weijun Zhou
19 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago
2
2
config.txt
has no newline at the end of the file. Fix that or simply add one before adding var2
.– RoVo
19 hours ago
config.txt
has no newline at the end of the file. Fix that or simply add one before adding var2
.– RoVo
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In
vim
, files without n
in the last line is indicated in the status line by [noeol]
.– Weijun Zhou
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In
vim
, files without n
in the last line is indicated in the status line by [noeol]
.– Weijun Zhou
19 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago
add a comment |
2 Answers
2
active
oldest
votes
Probably you should have inserted the text export var1=345476746
with -n
option initially.
-n
do not output the trailing newline
Example :
echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt
Results :
# more config.txt
export var1=345476746export var2=5645
add a comment |
Your config.txt
has no newline at the end of the file.
The posix standard says there should be:
3.206 Line
A sequence of zero or more non- characters plus a terminating <newline> character.
You can add a new line, e.g.:
sed -i -e '$a' config.txt
This will add a new line only when there is not already one at the end.
In your case a simple echo >> config.txt
would do the job.
A simpleecho >> config.txt
should do the work if it is just missing the finaln
.
– Weijun Zhou
19 hours ago
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
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
);
);
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%2f507359%2fnew-line-not-append-instead-append-on-the-end-of-the-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Probably you should have inserted the text export var1=345476746
with -n
option initially.
-n
do not output the trailing newline
Example :
echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt
Results :
# more config.txt
export var1=345476746export var2=5645
add a comment |
Probably you should have inserted the text export var1=345476746
with -n
option initially.
-n
do not output the trailing newline
Example :
echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt
Results :
# more config.txt
export var1=345476746export var2=5645
add a comment |
Probably you should have inserted the text export var1=345476746
with -n
option initially.
-n
do not output the trailing newline
Example :
echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt
Results :
# more config.txt
export var1=345476746export var2=5645
Probably you should have inserted the text export var1=345476746
with -n
option initially.
-n
do not output the trailing newline
Example :
echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt
Results :
# more config.txt
export var1=345476746export var2=5645
answered 14 hours ago
msp9011msp9011
4,44344167
4,44344167
add a comment |
add a comment |
Your config.txt
has no newline at the end of the file.
The posix standard says there should be:
3.206 Line
A sequence of zero or more non- characters plus a terminating <newline> character.
You can add a new line, e.g.:
sed -i -e '$a' config.txt
This will add a new line only when there is not already one at the end.
In your case a simple echo >> config.txt
would do the job.
A simpleecho >> config.txt
should do the work if it is just missing the finaln
.
– Weijun Zhou
19 hours ago
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
add a comment |
Your config.txt
has no newline at the end of the file.
The posix standard says there should be:
3.206 Line
A sequence of zero or more non- characters plus a terminating <newline> character.
You can add a new line, e.g.:
sed -i -e '$a' config.txt
This will add a new line only when there is not already one at the end.
In your case a simple echo >> config.txt
would do the job.
A simpleecho >> config.txt
should do the work if it is just missing the finaln
.
– Weijun Zhou
19 hours ago
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
add a comment |
Your config.txt
has no newline at the end of the file.
The posix standard says there should be:
3.206 Line
A sequence of zero or more non- characters plus a terminating <newline> character.
You can add a new line, e.g.:
sed -i -e '$a' config.txt
This will add a new line only when there is not already one at the end.
In your case a simple echo >> config.txt
would do the job.
Your config.txt
has no newline at the end of the file.
The posix standard says there should be:
3.206 Line
A sequence of zero or more non- characters plus a terminating <newline> character.
You can add a new line, e.g.:
sed -i -e '$a' config.txt
This will add a new line only when there is not already one at the end.
In your case a simple echo >> config.txt
would do the job.
edited 13 hours ago
answered 19 hours ago
RoVoRoVo
3,332317
3,332317
A simpleecho >> config.txt
should do the work if it is just missing the finaln
.
– Weijun Zhou
19 hours ago
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
add a comment |
A simpleecho >> config.txt
should do the work if it is just missing the finaln
.
– Weijun Zhou
19 hours ago
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
A simple
echo >> config.txt
should do the work if it is just missing the final n
.– Weijun Zhou
19 hours ago
A simple
echo >> config.txt
should do the work if it is just missing the final n
.– Weijun Zhou
19 hours ago
1
1
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
In this case yes, but it will append a newline if it's missing or not.
– RoVo
18 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.
– Stéphane Chazelas
14 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
@Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.
– RoVo
13 hours ago
add a comment |
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%2f507359%2fnew-line-not-append-instead-append-on-the-end-of-the-line%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
2
config.txt
has no newline at the end of the file. Fix that or simply add one before addingvar2
.– RoVo
19 hours ago
still not understand how to add "n" on each line , seems that last line isn't with "n"
– yael
19 hours ago
If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In
vim
, files withoutn
in the last line is indicated in the status line by[noeol]
.– Weijun Zhou
19 hours ago
possible duplicate of How to add a newline to the end of a file?
– Stéphane Chazelas
14 hours ago
See also What's the point in adding a new line to the end of a file?
– Stéphane Chazelas
14 hours ago