You are not logged in.

#1 2017-04-15 20:44:11

ccerna1
Member
Registered: 2016-03-07
Posts: 26

[SOLVED]Control+d not working in terminal

Good afternoon,
been spending  a few hours learning the terminal and was looking at the cat command

Looking to create a file and take the output of the terminal and save it to the file.

The examples I seen online are as follow:

cat > file1 i will add some text inthe file1

At the end of the last word on my text which would be file1 I supposed to hit CTRL+d 
I do  but nothing happens the file is created without any text.

Not sure if am not selecting the correct key combination or the syntax is wrong
using xfce4-terminal if that helps.

Last edited by ccerna1 (2017-04-16 03:37:43)

Offline

#2 2017-04-15 20:52:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED]Control+d not working in terminal

Ctrl-d sends and EOF symbol or "End of file".  It will close a shell session if used at a prompt.  But in your "cat" use it would just end the file.  However, to be used as an end of file for "cat" (getting input from stdin, i.e. the keyboard) you need to press Ctrl-d on a new line.  So hit Enter after your last line of text, then hit ctrl-d.

Honestly, I'm not sure why this is.  A file can end without a last newline character.  So in principle one should be able to send the EOF from anywhere.  But in practice it doesn't seem to work that way when reading from keyboard-stdin.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2017-04-15 21:10:33

ccerna1
Member
Registered: 2016-03-07
Posts: 26

Re: [SOLVED]Control+d not working in terminal

So a couple of things I notice my locale was not set duh! me after a whole year using this... selected the correct one and generated a new locale.
check the keyboard setting was set at default and now is Generic 105 key.

When I run the command I get this:
cat > file1 this is a test
cat: is: No such file or directory
cat: a: No such file or directory
cat: test: No such file or directory

when i check the directory the file is created but is empty.
I hit enter as you stated and in the new line ctrl d and it closed the terminal

Offline

#4 2017-04-15 21:28:56

ccerna1
Member
Registered: 2016-03-07
Posts: 26

Re: [SOLVED]Control+d not working in terminal

Ok I notice what I was doing wrong you were correct
first
cat > file1 (hit enter and will take me to line below without a terminal prompt)
there is no terminal prompt here so I write the text
text
text
I hit control d here and will save the text to the file

Offline

#5 2017-04-15 21:34:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED]Control+d not working in terminal

Ah, yes, you need to hit enter after a command as well before it even starts listening for input.  Technically you could use a herestring to have input on the same line, but that lesson will likely come quite a bit later in your learning.

If you are not already using it, I'd suggest you read through Greg's wiki which is the de-facto standard bash tutorial.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2017-04-15 21:38:47

ccerna1
Member
Registered: 2016-03-07
Posts: 26

Re: [SOLVED]Control+d not working in terminal

Great thank you for setting me in the right path!

Offline

Board footer

Powered by FluxBB