0

I have to do it with the find command. Now i have this:

sudo find /home/jesus/ -type d -exec touch {}/folder.txt \;

I want that inside each directory is created a file that starts with the same name as the directory and adds the name folder.txt

if I execute my command it creates the files with the correct names but not inside each directory

0

In the find command, make use of -execdir instead of -exec, so the touch-command will be executed in the directory where find found a match. Use

find /path/to/directory -type d -execdir touch "{}"/folder.txt \;

or

find /path/to/directory -type d -execdir touch "{}"/"{}"folder.txt \;

depending on your desired file-name. The command you used does not produce the file-name you described in your question,so it's not really clear to me what you need here, but you can modify this examples to fulfill your needs. The first example matches the command you used, the second example matches your description.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.