Should the last line in a configuration file have a newline after it?
up vote
2
down vote
favorite
I sometimes whether I should put a newline after the last line in a configuration file, especially if it is a one-line configuration file, like the hostname file.
Does it not matter, or is there a rule?
configuration
add a comment |
up vote
2
down vote
favorite
I sometimes whether I should put a newline after the last line in a configuration file, especially if it is a one-line configuration file, like the hostname file.
Does it not matter, or is there a rule?
configuration
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I sometimes whether I should put a newline after the last line in a configuration file, especially if it is a one-line configuration file, like the hostname file.
Does it not matter, or is there a rule?
configuration
I sometimes whether I should put a newline after the last line in a configuration file, especially if it is a one-line configuration file, like the hostname file.
Does it not matter, or is there a rule?
configuration
configuration
asked Nov 29 at 0:50
Tyler Durden
1,52841849
1,52841849
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48
add a comment |
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48
add a comment |
1 Answer
1
active
oldest
votes
up vote
7
down vote
Yes, the last character of a valid POSIX text file must be a newline.
It has been debated before.
It is easy (and very fast) to correct a file (if needed).
And vim might be configured to automatically ensure that a trail newline is included.
It matters in the sense that some tools expect a text file, and therefore expect an ending newline. For example the shell read
will fail (unless configured in a special way) to read the last line of a text file that is missing a newline. And concatenation of files with cat
will also require special handling.
You can not follow the recomendations to reduce one byte per file, but at the cost of added complexities to process files. It is not worth the trouble IMO.
I can not think of any other reason to avoid having an ending newline for a text file.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
Yes, the last character of a valid POSIX text file must be a newline.
It has been debated before.
It is easy (and very fast) to correct a file (if needed).
And vim might be configured to automatically ensure that a trail newline is included.
It matters in the sense that some tools expect a text file, and therefore expect an ending newline. For example the shell read
will fail (unless configured in a special way) to read the last line of a text file that is missing a newline. And concatenation of files with cat
will also require special handling.
You can not follow the recomendations to reduce one byte per file, but at the cost of added complexities to process files. It is not worth the trouble IMO.
I can not think of any other reason to avoid having an ending newline for a text file.
add a comment |
up vote
7
down vote
Yes, the last character of a valid POSIX text file must be a newline.
It has been debated before.
It is easy (and very fast) to correct a file (if needed).
And vim might be configured to automatically ensure that a trail newline is included.
It matters in the sense that some tools expect a text file, and therefore expect an ending newline. For example the shell read
will fail (unless configured in a special way) to read the last line of a text file that is missing a newline. And concatenation of files with cat
will also require special handling.
You can not follow the recomendations to reduce one byte per file, but at the cost of added complexities to process files. It is not worth the trouble IMO.
I can not think of any other reason to avoid having an ending newline for a text file.
add a comment |
up vote
7
down vote
up vote
7
down vote
Yes, the last character of a valid POSIX text file must be a newline.
It has been debated before.
It is easy (and very fast) to correct a file (if needed).
And vim might be configured to automatically ensure that a trail newline is included.
It matters in the sense that some tools expect a text file, and therefore expect an ending newline. For example the shell read
will fail (unless configured in a special way) to read the last line of a text file that is missing a newline. And concatenation of files with cat
will also require special handling.
You can not follow the recomendations to reduce one byte per file, but at the cost of added complexities to process files. It is not worth the trouble IMO.
I can not think of any other reason to avoid having an ending newline for a text file.
Yes, the last character of a valid POSIX text file must be a newline.
It has been debated before.
It is easy (and very fast) to correct a file (if needed).
And vim might be configured to automatically ensure that a trail newline is included.
It matters in the sense that some tools expect a text file, and therefore expect an ending newline. For example the shell read
will fail (unless configured in a special way) to read the last line of a text file that is missing a newline. And concatenation of files with cat
will also require special handling.
You can not follow the recomendations to reduce one byte per file, but at the cost of added complexities to process files. It is not worth the trouble IMO.
I can not think of any other reason to avoid having an ending newline for a text file.
answered Nov 29 at 4:05
Isaac
10.1k11445
10.1k11445
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f484802%2fshould-the-last-line-in-a-configuration-file-have-a-newline-after-it%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
It's useful if you want to append to it.
– Ben
Nov 29 at 0:55
See unix.stackexchange.com/q/18743/185953
– Ben
Nov 29 at 0:57
it is unclear what you are asking ......are you talking about a file that has two newlines at the end, one at end of line and a second one after that line? ..... are you talking about only one newline at the end? .... are you talking about no newline at the end?
– jsotola
Nov 30 at 2:48