I have 5 empty directories:
[X]$ ls
dir_1 dir_2 dir_3 dir_4 dir_5
How can I make a text file in every one of these directories so that the text file would contain the name of the directory it is in? So for example, dir_1 would contain text file file_1.txt and this text file has text dir_1 in it, dir_2 contains text file file_2.txt that has text dir_2 in it and so on.
I searched for information but I couldn't figure this out. I started to learn linux very recently. Do I have to do something like:
find . -type d -exec touch (something?)
And is it possible to do this with for loops?
dir_*/as the pattern to avoid non-directories, such asdir_listfile. – Kusalananda May 22 '20 at 19:29