The lazy me is thinking about adding a column to some textfiles.
The textfiles are in directories and I would like to add the directory name to the text file.
Like the text file text.txt in the folder the_peasant:
has a wart
was dressed up like a witch
has a false nose
would become:
the_peasant has a wart
the_peasant was dressed up like a witch
the_peasant has a false nose
Then I have similar text files in other folders called “the_king” etc.
I would think this is a combination of the find command, bash scripting and sed but I cant see it through. Any ideas?
The directory tree:
Directories and contents before:
Code (wart.py):
Which outputs:
Directories and contents after:
This was fun! Thanks for the challenge!