cat shows file contents, gedit and vim show blank file
Clash Royale CLAN TAG#URR8PPP
I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook.
The Serial console showed no errors, so I assumed everything worked perfectly.
However... when I inserted the card in my computer (Ubuntu 18.04) and opened it with gedit, the file was blank? Vim had the same behaviour: it was blank.
But... when I used cat on the file, it DID show the contents?!
Anyone have a clue what I did wrong here?
EDIT: in reponse to Bodo's question:
output of cat:
...
TEST
TEST
TEST
TEST
TEST
TEST
372,345,324
342,340,330
331,332,328
327,325,324
322,320,318
317,315,313
313,310,309
...
(This is what's supposed to be in there)
out put of ls -l:
total 16
-rw-r--r-- 1 myname myname 15161 Jan 1 2000 DATALOG.TXT
output of od -c -tx1 DATALOG.TXT | head -1 :
0000000 r n r n r n r n r n r n r n r n
This last one answerd the question to me... It shows a bunch of newlines. But really... A LOT... This explains why gedit and vim showed empty files. I have to scroll down for ages before seeing the actual data. When using cat, I only saw the trailing lines, so it showed the contents.
Probably something that went wrong when saving the data to the SD-card. Thanks Bodo! You solved my problem merely by posing a question :D
files vim cat gedit
add a comment |
I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook.
The Serial console showed no errors, so I assumed everything worked perfectly.
However... when I inserted the card in my computer (Ubuntu 18.04) and opened it with gedit, the file was blank? Vim had the same behaviour: it was blank.
But... when I used cat on the file, it DID show the contents?!
Anyone have a clue what I did wrong here?
EDIT: in reponse to Bodo's question:
output of cat:
...
TEST
TEST
TEST
TEST
TEST
TEST
372,345,324
342,340,330
331,332,328
327,325,324
322,320,318
317,315,313
313,310,309
...
(This is what's supposed to be in there)
out put of ls -l:
total 16
-rw-r--r-- 1 myname myname 15161 Jan 1 2000 DATALOG.TXT
output of od -c -tx1 DATALOG.TXT | head -1 :
0000000 r n r n r n r n r n r n r n r n
This last one answerd the question to me... It shows a bunch of newlines. But really... A LOT... This explains why gedit and vim showed empty files. I have to scroll down for ages before seeing the actual data. When using cat, I only saw the trailing lines, so it showed the contents.
Probably something that went wrong when saving the data to the SD-card. Thanks Bodo! You solved my problem merely by posing a question :D
files vim cat gedit
1
Show the output ofls -l /location/of/your/sdcard
. What doescat yourfile
show? Orod -c -tx1 yourfile | head -10
?
– Bodo
Feb 27 at 10:50
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
1
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
1
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04
add a comment |
I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook.
The Serial console showed no errors, so I assumed everything worked perfectly.
However... when I inserted the card in my computer (Ubuntu 18.04) and opened it with gedit, the file was blank? Vim had the same behaviour: it was blank.
But... when I used cat on the file, it DID show the contents?!
Anyone have a clue what I did wrong here?
EDIT: in reponse to Bodo's question:
output of cat:
...
TEST
TEST
TEST
TEST
TEST
TEST
372,345,324
342,340,330
331,332,328
327,325,324
322,320,318
317,315,313
313,310,309
...
(This is what's supposed to be in there)
out put of ls -l:
total 16
-rw-r--r-- 1 myname myname 15161 Jan 1 2000 DATALOG.TXT
output of od -c -tx1 DATALOG.TXT | head -1 :
0000000 r n r n r n r n r n r n r n r n
This last one answerd the question to me... It shows a bunch of newlines. But really... A LOT... This explains why gedit and vim showed empty files. I have to scroll down for ages before seeing the actual data. When using cat, I only saw the trailing lines, so it showed the contents.
Probably something that went wrong when saving the data to the SD-card. Thanks Bodo! You solved my problem merely by posing a question :D
files vim cat gedit
I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook.
The Serial console showed no errors, so I assumed everything worked perfectly.
However... when I inserted the card in my computer (Ubuntu 18.04) and opened it with gedit, the file was blank? Vim had the same behaviour: it was blank.
But... when I used cat on the file, it DID show the contents?!
Anyone have a clue what I did wrong here?
EDIT: in reponse to Bodo's question:
output of cat:
...
TEST
TEST
TEST
TEST
TEST
TEST
372,345,324
342,340,330
331,332,328
327,325,324
322,320,318
317,315,313
313,310,309
...
(This is what's supposed to be in there)
out put of ls -l:
total 16
-rw-r--r-- 1 myname myname 15161 Jan 1 2000 DATALOG.TXT
output of od -c -tx1 DATALOG.TXT | head -1 :
0000000 r n r n r n r n r n r n r n r n
This last one answerd the question to me... It shows a bunch of newlines. But really... A LOT... This explains why gedit and vim showed empty files. I have to scroll down for ages before seeing the actual data. When using cat, I only saw the trailing lines, so it showed the contents.
Probably something that went wrong when saving the data to the SD-card. Thanks Bodo! You solved my problem merely by posing a question :D
files vim cat gedit
files vim cat gedit
edited Feb 27 at 10:55
Opifex
asked Feb 27 at 10:43
OpifexOpifex
113
113
1
Show the output ofls -l /location/of/your/sdcard
. What doescat yourfile
show? Orod -c -tx1 yourfile | head -10
?
– Bodo
Feb 27 at 10:50
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
1
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
1
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04
add a comment |
1
Show the output ofls -l /location/of/your/sdcard
. What doescat yourfile
show? Orod -c -tx1 yourfile | head -10
?
– Bodo
Feb 27 at 10:50
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
1
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
1
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04
1
1
Show the output of
ls -l /location/of/your/sdcard
. What does cat yourfile
show? Or od -c -tx1 yourfile | head -10
?– Bodo
Feb 27 at 10:50
Show the output of
ls -l /location/of/your/sdcard
. What does cat yourfile
show? Or od -c -tx1 yourfile | head -10
?– Bodo
Feb 27 at 10:50
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
1
1
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
1
1
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04
add a comment |
1 Answer
1
active
oldest
votes
As already shown in the edit, here's the answer:
executing od -c -tx1 DATALOG.TXT | head -1
gave me this:
0000000 r n r n r n r n r n r n r n r n
This hinted me that the file might have a bunch of newlines at the beginning, with the contents trailing.
This turned out to be the case. That is why the file appeared empty in gedit and vim, but not with cat. Because I would only see the last lines of cat in terminal.
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%2f503300%2fcat-shows-file-contents-gedit-and-vim-show-blank-file%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
As already shown in the edit, here's the answer:
executing od -c -tx1 DATALOG.TXT | head -1
gave me this:
0000000 r n r n r n r n r n r n r n r n
This hinted me that the file might have a bunch of newlines at the beginning, with the contents trailing.
This turned out to be the case. That is why the file appeared empty in gedit and vim, but not with cat. Because I would only see the last lines of cat in terminal.
add a comment |
As already shown in the edit, here's the answer:
executing od -c -tx1 DATALOG.TXT | head -1
gave me this:
0000000 r n r n r n r n r n r n r n r n
This hinted me that the file might have a bunch of newlines at the beginning, with the contents trailing.
This turned out to be the case. That is why the file appeared empty in gedit and vim, but not with cat. Because I would only see the last lines of cat in terminal.
add a comment |
As already shown in the edit, here's the answer:
executing od -c -tx1 DATALOG.TXT | head -1
gave me this:
0000000 r n r n r n r n r n r n r n r n
This hinted me that the file might have a bunch of newlines at the beginning, with the contents trailing.
This turned out to be the case. That is why the file appeared empty in gedit and vim, but not with cat. Because I would only see the last lines of cat in terminal.
As already shown in the edit, here's the answer:
executing od -c -tx1 DATALOG.TXT | head -1
gave me this:
0000000 r n r n r n r n r n r n r n r n
This hinted me that the file might have a bunch of newlines at the beginning, with the contents trailing.
This turned out to be the case. That is why the file appeared empty in gedit and vim, but not with cat. Because I would only see the last lines of cat in terminal.
answered Feb 27 at 11:06
OpifexOpifex
113
113
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%2f503300%2fcat-shows-file-contents-gedit-and-vim-show-blank-file%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
1
Show the output of
ls -l /location/of/your/sdcard
. What doescat yourfile
show? Orod -c -tx1 yourfile | head -10
?– Bodo
Feb 27 at 10:50
@Bodo: I added the outputs to the question. But... by executing those, I was able to figure it out (see edit). Thanks a lot!
– Opifex
Feb 27 at 10:56
1
@Opifex I suggest you answer the question instead of editing the question. Should be helpful to figure out for others in future.
– Atul
Feb 27 at 11:02
Relevant: Can I answer my own question?
– Kamil Maciorowski
Feb 27 at 11:02
1
Ok, will do! Thanks @Atul and @KamilMaciorowski!
– Opifex
Feb 27 at 11:04