How to create multiple files in `testdir`?

QuestionsQuestions8 SkillsProDec, 17 2025
0102

That's a great question! There are a few efficient ways to create multiple files at once in Linux.

Here are the most common methods to create files inside your testdir:

1. Using touch with multiple names

The touch command can take multiple arguments. You just need to separate the file paths with a space:

touch testdir/fileA.txt testdir/fileB.txt testdir/fileC.txt

2. Using "Brace Expansion" (The Pro Way)

Linux has a powerful feature called "brace expansion" that saves you from typing the directory name over and over:

touch testdir/file{1,2,3}.txt

This will create file1.txt, file2.txt, and file3.txt all at once inside testdir.

3. Creating a sequence

If you need many files (like 10 or 100), you can use a range:

touch testdir/demo{1..5}.txt

This creates demo1.txt, demo2.txt, demo3.txt, demo4.txt, and demo5.txt.

How to verify:

After running any of the commands above, use the command you asked about earlier to see the results:

ls -l testdir

Give one of those a try in your terminal

0 Comments

no data
Be the first to share your comment!