tontontv
tontontv

Reputation: 81

create a file called hello.txt that contains the word "hello world"?

question is as bellow:-

create a file called hello.txt that contains the words "hello world",. can you use "cp" using "terminal" as the source file to achieve the same effect?

i already create a text file and name as hello.txt. then i type a command in linux terminal asbellow:-

cp hello.txt /home/tobenrry

but it is error and cannot get the output. i try many command already for creating this. but it is also not work. may i knows what the the command for the question?

Upvotes: 0

Views: 4892

Answers (3)

user2929279
user2929279

Reputation: 27

say terminal = /dev/tty

type the following commands:

cat >terminal

"enter the txt here say "hello world" " ctrl+D

cp terminal destinationfilename

Upvotes: 0

Robin Green
Robin Green

Reputation: 33083

On Linux the current terminal is identified by the device /dev/tty, so you can do:

cp /dev/tty hello.txt

That's what the question is asking for.

Upvotes: 1

sehe
sehe

Reputation: 393507

copy from stdin to file:

 cp /dev/stdin $HOME/test.txt
 cat > $HOME/test.txt

 cat /dev/tty > test.txt

Upvotes: 0

Related Questions