P
P
Pavel2015-12-28 17:02:30
Command line
Pavel, 2015-12-28 17:02:30

Is it possible through the terminal, command line to create a file immediately with the contents?

It doesn't matter unix command or windows cmd. I would like to enter something like touch name.txt {'file content'} and get the result.
Thanks

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
anykey_ua, 2015-12-28
@mrusklon

This is under Windows
echo 'File contents'>> 1.txt

V
Vlad Zhivotnev, 2015-12-28
@inkvizitor68sl

On *nix:
cat > file << EOF
blablabla
EOF
Or
echo "blabla" > file

V
Vladimir Martyanov, 2015-12-28
@vilgeforce

echo rtfm > file.bin

A
Apolakov, 2015-12-28
@Apolakov

under Win - the command copy con - example - copy con blah.txt - will create a file and write into it what you enter from the keyboard.
Under unix, the echo »blabla command will create a file and write what you type into it.
Well, this is just an example. In general, no one canceled the help and man commands; they work in terminals.

A
Alexey Ukolov, 2015-12-28
@alexey-m-ukolov

For multiline input, you can use the following command:cat > file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question