Reputation: 81
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
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
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
Reputation: 393507
copy from stdin to file:
cp /dev/stdin $HOME/test.txt
cat > $HOME/test.txt
cat /dev/tty > test.txt
Upvotes: 0