Invoker
Invoker

Reputation: 248

What is a command to create a file on Linux?

For testing purposes I have to create a file with 1000 lines in it with one command.

What is a command to create a file on Linux?

Upvotes: 1

Views: 173

Answers (3)

Kasun Rathnayaka
Kasun Rathnayaka

Reputation: 503

you use the above for loop use print something $c times in text.txt.$c is number of runnning time (1,2,4...10000)

for (( c=1; c<=1000; c++ ));do echo "something $c times">>test.txt ;done

Upvotes: 0

Maoz Zadok
Maoz Zadok

Reputation: 5920

for x in `seq 1 1000`; do echo "sometext" $x >>file.txt; done

Upvotes: 1

jangler
jangler

Reputation: 987

touch is usually used to create empty files, but if you want to create a non-empty file, just redirect the output of some command to that file, like in the first line of this example:

$ echo hello world > greeting.txt
$ cat greeting.txt
hello world

A way to create a file with 1000 lines would be:

$ seq 1000 > file

Upvotes: 2

Related Questions