With zsh
:
touch -- README **/*(N/e[REPLY+=/README])
It combines recursive globbing (**/*
) with glob qualifiers, which here are:
N
ullglob: doesn't trigger an error if there's no match.
/
: restrict to files of type directory
e[code]
: e
valuates the code
for each file, here appending /README
to file path (stored in $REPLY
in the evaluated code).
Or you could use an anonymous function which is passed the list of directories, and which appends the /README
to each in the arguments it passes to touch
:
() {touch -- $^@/README} . **/*(N/)
(with rc-style array expansion for the anonymous function @
rguments using the $^array
syntax).
In all those, you can add the D
otglob glob qualifier to also add README
to hidden directories.