Why does wc -l tell me that this non-empty file has 0 lines? The 2019 Stack Overflow Developer Survey Results Are InBash test wc with '-ge' - division by 0 errorGet last set of non-empty linesHow can I delete lines that has an empty first column?What does this “matching lines means”?Why the inconsistency with using cat vs. echo piped to this sed command?How many lines of code are in this file?Calling latex from vim stopped workingprint only rows that has latest non empty cell that starts with the word “Failed” on a CSV file in LinuxHow to exclude lines that has given columns?How to remove the lines that have empty fields?Trying to print full line from a huge file that has (connector for lines)
What did it mean to "align" a radio?
Can you compress metal and what would be the consequences?
Interpreting the 2019 New York Reproductive Health Act?
How to check whether the reindex working or not in Magento?
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
Reference request: Oldest number theory books with (unsolved) exercises?
What does ひと匙 mean in this manga and has it been used colloquially?
Return to UK after having been refused entry years ago
Is a "Democratic" Oligarchy-Style System Possible?
Falsification in Math vs Science
Have you ever entered Singapore using a different passport or name?
Feature engineering suggestion required
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Am I thawing this London Broil safely?
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
How are circuits which use complex ICs normally simulated?
Looking for Correct Greek Translation for Heraclitus
Does the shape of a die affect the probability of a number being rolled?
Why isn't the circumferential light around the M87 black hole's event horizon symmetric?
Does coating your armor in silver add any effects?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
If a Druid sees an animal’s corpse, can they Wild Shape into that animal?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
When should I buy a clipper card after flying to OAK?
Why does wc -l tell me that this non-empty file has 0 lines?
The 2019 Stack Overflow Developer Survey Results Are InBash test wc with '-ge' - division by 0 errorGet last set of non-empty linesHow can I delete lines that has an empty first column?What does this “matching lines means”?Why the inconsistency with using cat vs. echo piped to this sed command?How many lines of code are in this file?Calling latex from vim stopped workingprint only rows that has latest non empty cell that starts with the word “Failed” on a CSV file in LinuxHow to exclude lines that has given columns?How to remove the lines that have empty fields?Trying to print full line from a huge file that has (connector for lines)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
xclip
/xsel
are utilities that allow you to pipe clipboard output to the shell on Ubuntu. Unfortunately, they seem to fail in combination with the wc
command.
Try this. Open a new file and type:
this is a line
without hitting the enter key at the end of the line.
Now, copy this text and try the following:
$ xsel -o | wc -l
0
The output is 0, when in fact it should be 1. Save the file (call it myfile.txt
).
Now try:
$ cat myfile.txt | wc -l
1
The output is 1, as expected.
Why is the output 0 in the first case?
text-processing newlines wc
add a comment |
xclip
/xsel
are utilities that allow you to pipe clipboard output to the shell on Ubuntu. Unfortunately, they seem to fail in combination with the wc
command.
Try this. Open a new file and type:
this is a line
without hitting the enter key at the end of the line.
Now, copy this text and try the following:
$ xsel -o | wc -l
0
The output is 0, when in fact it should be 1. Save the file (call it myfile.txt
).
Now try:
$ cat myfile.txt | wc -l
1
The output is 1, as expected.
Why is the output 0 in the first case?
text-processing newlines wc
add a comment |
xclip
/xsel
are utilities that allow you to pipe clipboard output to the shell on Ubuntu. Unfortunately, they seem to fail in combination with the wc
command.
Try this. Open a new file and type:
this is a line
without hitting the enter key at the end of the line.
Now, copy this text and try the following:
$ xsel -o | wc -l
0
The output is 0, when in fact it should be 1. Save the file (call it myfile.txt
).
Now try:
$ cat myfile.txt | wc -l
1
The output is 1, as expected.
Why is the output 0 in the first case?
text-processing newlines wc
xclip
/xsel
are utilities that allow you to pipe clipboard output to the shell on Ubuntu. Unfortunately, they seem to fail in combination with the wc
command.
Try this. Open a new file and type:
this is a line
without hitting the enter key at the end of the line.
Now, copy this text and try the following:
$ xsel -o | wc -l
0
The output is 0, when in fact it should be 1. Save the file (call it myfile.txt
).
Now try:
$ cat myfile.txt | wc -l
1
The output is 1, as expected.
Why is the output 0 in the first case?
text-processing newlines wc
text-processing newlines wc
edited Apr 13 '17 at 12:22
Community♦
1
1
asked Jul 17 '13 at 18:51
CodeBlueCodeBlue
51751020
51751020
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The issue you're experiencing is that wc -l
counts new lines. Since you haven't in fact typed the n
there is in fact zero new lines.
excerpt from wc
man page
Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of
characters delimited by white space.
If you switch it around so that wc
counts characters (-c
) you'll see that it is in fact working just fine and can count the number of characters:
$ xsel -o | wc -c
14
Saving it to a file has the effect of adding a newline at the end of the file.
add a comment |
wc
counts the end of line characters. The first time you just marked the text, not containing any end of line character. When you save the file, the editor appends an end of line character which is counted by wc
.
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%2f83408%2fwhy-does-wc-l-tell-me-that-this-non-empty-file-has-0-lines%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
The issue you're experiencing is that wc -l
counts new lines. Since you haven't in fact typed the n
there is in fact zero new lines.
excerpt from wc
man page
Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of
characters delimited by white space.
If you switch it around so that wc
counts characters (-c
) you'll see that it is in fact working just fine and can count the number of characters:
$ xsel -o | wc -c
14
Saving it to a file has the effect of adding a newline at the end of the file.
add a comment |
The issue you're experiencing is that wc -l
counts new lines. Since you haven't in fact typed the n
there is in fact zero new lines.
excerpt from wc
man page
Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of
characters delimited by white space.
If you switch it around so that wc
counts characters (-c
) you'll see that it is in fact working just fine and can count the number of characters:
$ xsel -o | wc -c
14
Saving it to a file has the effect of adding a newline at the end of the file.
add a comment |
The issue you're experiencing is that wc -l
counts new lines. Since you haven't in fact typed the n
there is in fact zero new lines.
excerpt from wc
man page
Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of
characters delimited by white space.
If you switch it around so that wc
counts characters (-c
) you'll see that it is in fact working just fine and can count the number of characters:
$ xsel -o | wc -c
14
Saving it to a file has the effect of adding a newline at the end of the file.
The issue you're experiencing is that wc -l
counts new lines. Since you haven't in fact typed the n
there is in fact zero new lines.
excerpt from wc
man page
Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of
characters delimited by white space.
If you switch it around so that wc
counts characters (-c
) you'll see that it is in fact working just fine and can count the number of characters:
$ xsel -o | wc -c
14
Saving it to a file has the effect of adding a newline at the end of the file.
edited Jul 17 '13 at 19:20
answered Jul 17 '13 at 19:14
slm♦slm
256k71544689
256k71544689
add a comment |
add a comment |
wc
counts the end of line characters. The first time you just marked the text, not containing any end of line character. When you save the file, the editor appends an end of line character which is counted by wc
.
add a comment |
wc
counts the end of line characters. The first time you just marked the text, not containing any end of line character. When you save the file, the editor appends an end of line character which is counted by wc
.
add a comment |
wc
counts the end of line characters. The first time you just marked the text, not containing any end of line character. When you save the file, the editor appends an end of line character which is counted by wc
.
wc
counts the end of line characters. The first time you just marked the text, not containing any end of line character. When you save the file, the editor appends an end of line character which is counted by wc
.
answered Jul 17 '13 at 19:15
MarcoMarco
25.5k784120
25.5k784120
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.
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%2f83408%2fwhy-does-wc-l-tell-me-that-this-non-empty-file-has-0-lines%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
-newlines, text-processing, wc