3 Matching Annotations
- Feb 2024
-
unix.stackexchange.com unix.stackexchange.com
-
if [ "$#" -eq 0 ]; then cat else printf '%s\n' "$@" fi |
-
-
unix.stackexchange.com unix.stackexchange.com
-
if [ "$#" -ne 0 ] then printf '%s\n' "$1" else cat fi |
Comparible to this solution for the case of a script file (rather than function): https://hyp.is/6UIWdNaREe6L5DMx96BIOA/unix.stackexchange.com/questions/580971/how-to-write-a-script-that-accepts-input-from-stdin-or-a-file
-
Well, here’s a non-recursive solution in which the main commands appear only once:
-