How to create multiple files in different directories?

QuestionsQuestions4 SkillsProBasic Files OperationsSep, 19 2025
0199

To create multiple files in different directories, you can use the mkdir command to create the directories first, followed by the touch command to create the files within those directories. Here’s how to do it:

Step 1: Create Directories

mkdir -p dir1 dir2 dir3

Step 2: Create Files in Each Directory

touch dir1/file1.txt dir2/file2.txt dir3/file3.txt

Explanation:

  • The -p option in mkdir creates the directories if they do not exist.
  • The touch command creates the specified files in their respective directories.

Verification:

To check that the files were created, you can use:

ls -R

This will list all files and directories recursively. If you have any further questions or need assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!