4 ms·
I really like this; reminiscent of the Python Challenge, but for shell. You should support bash's double-star wildcard, which works recursively. Several of th
by JoshTriplett 10y ago
I really like this; reminiscent of the Python Challenge, but for shell.
You should support bash's double-star wildcard, which works recursively. Several of the challenges that currently require
find -name 'access.log*' -print0 | xargs -0 somecommand
could just use
somecommand **/access.log*
instead.
You might also encourage people to look up manpages. For instance, someone who doesn't know about "grep -h" may want to look at the manpage for grep. You could make "man grep" link to http://man7.org/linux/man-pages/man1/grep.1.html http://man7.org/linux/man-pages/man1/grep.1.html .
Tab completion doesn't always include all files; for instance, it doesn't include split-me.txt
Have you considered logging all unique successful solutions (filtering out minor whitespace differences) to each challenge? That would let people who have completed each challenge see other potential approaches to the problem, and perhaps learn about new commands.
- zokier 10y ago> You should support bash's double-star wildcard, which works recursively It depends on what the educational goals are, but alternatively OP could swing on the opposite direction and go with a very vanilla POSIX sh style shell (maybe dash) to discourage bashisms. I might of course be bit biased because `find` is one of my favorite utils (generally with -exec instead of -print0|xargs -0) and I practically never use newfangled doublestar globbing
- JoshTriplett 10y agoTeaching efficient bash usage and teaching portable shell scripting seem related but distinct. This challenge specifically mentions that it uses bash.
- zokier 10y agoYes sure, I wasn't trying to say that going full bash is a bad thing. I was merely presenting an alternative.
- zoidb 10y agoAh good point, the commands are run in a bash 4 subshell actually but by default the globstar option is off.
- zoidb 10y agoglobstar is on by default now so this will work.
- saghm 10y ago> I really like this; reminiscent of the Python Challenge, but for shell. > You should support bash's double-star wildcard, which works recursively. Several of the challenges that currently require > find -name 'access.log' -print0 | xargs -0 somecommand > could just use > somecommand /access.log This challenge was where I stopped, and for this exact reason. Then again, I am a zsh user, so maybe I'm spoiled...
- Snowe 10y agoI stopped after 'Print the relative file paths, one path per line for all files that start with "access.log" in the current directory.' It didn't like my BSD find options.
- JoshTriplett 10y ago> It didn't like my BSD find options. Which options, specifically?
- bmoyles 10y agoYou can use shopt -s globstar and **/access.log* works just it would in bash :)
- JoshTriplett 10y agoI actually submitted a PR upstream, and the author merged it and deployed it, so cmdchallenge.com now has globstar enabled.