Skip to main content
added 652 characters in body
Source Link
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

With zsh:

touch -- README **/*(N/e[REPLY+=/README])

It combines recursive globbing (**/*) with glob qualifiers, which here are:

  • Nullglob: doesn't trigger an error if there's no match.
  • /: restrict to files of type directory
  • e[code]: evaluates 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 Dotglob glob qualifier to also add README to hidden directories.

With zsh:

touch -- README **/*(N/e[REPLY+=/README])

It combines recursive globbing (**/*) with glob qualifiers, which here are:

  • Nullglob: doesn't trigger an error if there's no match.
  • /: restrict to files of type directory
  • e[code]: evaluates 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 zsh:

touch -- README **/*(N/e[REPLY+=/README])

It combines recursive globbing (**/*) with glob qualifiers, which here are:

  • Nullglob: doesn't trigger an error if there's no match.
  • /: restrict to files of type directory
  • e[code]: evaluates 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 Dotglob glob qualifier to also add README to hidden directories.

added 652 characters in body
Source Link
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

With zsh:

touch -- README **/*(N/e[REPLY+=/README])

It combines recursive globbing (**/*) with glob qualifiers, which here are:

  • Nullglob: doesn't trigger an error if there's no match.
  • /: restrict to files of type directory
  • e[code]: evaluates 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 zsh:

touch -- README **/*(N/e[REPLY+=/README])

With zsh:

touch -- README **/*(N/e[REPLY+=/README])

It combines recursive globbing (**/*) with glob qualifiers, which here are:

  • Nullglob: doesn't trigger an error if there's no match.
  • /: restrict to files of type directory
  • e[code]: evaluates 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/)
Source Link
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

With zsh:

touch -- README **/*(N/e[REPLY+=/README])