Quickly create and delete multiple files or directories

Mkdir and Touch
I am pretty sure most of you already know what the mkdir command does.
Maybe new users won’t know too much about touch which is a great commandline tool which comes as part of the Gnu Coreutils.

For more information in the terminal type:
info coreutils touch invocation
and
man mkdir

To create multiple directories with the same name but a different number:
mkdir dir{1,2,3}

Which will give you:

dir1 dir2 dir3

To remove them:
rmdir dir{1,2,3}

To create multiple files with the same name but a different number:
touch file{1,2,3}.txt

Which will give you:

file1.txt file2.txt file2.txt

To remove them:
rm file{1,2,3}.txt

Advertisements

6 thoughts on “Quickly create and delete multiple files or directories

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s