How to create many files quickly?

QuestionsQuestions8 SkillsProBasic Files OperationsOct, 01 2025
084

You can create multiple files quickly using a loop in the terminal. Here are a couple of methods:

Using a for loop in Bash

for i in {1..10}; do touch file$i.txt; done

This command will create 10 files named file1.txt, file2.txt, ..., file10.txt.

Using seq and xargs

seq 1 10 | xargs -I {} touch file{}.txt

This will achieve the same result, creating files from file1.txt to file10.txt.

Using echo with redirection

If you want to create files with specific content, you can use:

for i in {1..10}; do echo "This is file $i" > file$i.txt; done

This will create 10 files with the specified content. Adjust the range {1..10} as needed for more or fewer files.

0 Comments

no data
Be the first to share your comment!