cmdchallenge
cmdchallenge copied to clipboard
list_files example doesn't allow "ls -l"
Normal GNU ls doesn't display one file per line but puts multiple files onto the same line. That's why I thought you specifically asked for ls -l
but I was suprised it didn't work. Then I tried ls -l | cut -d" " -f9-
, maybe you only wanted the file names, but that didn't work either.
Because the command you type is executed outside a terminal session (not in the javascript but executed remotely) the output comes back as a single line. You can do this explicitly in your terminal as ls -1
. Seems like people are confused about this, you aren't the first one to complain so I will try to make it clearer.
My first try was ls -a1
without a success.
Think the wording could be changed a little as I found this confusing:
List all of the files in the current directory, one file per line.
In unix terminals this command would be ls -l
but that returns as an error.
My suggestion would be to change wording to:
List all of the files in the current directory
This keeps the tested command (ls
) at its most basic without the confusion for experienced terminal users.
If there are dotted files, ls
alone does not lists all the files. ls -a
does.
My suggestion: put some dotted files there and make it more challenging. :wink:
+1 for this challenge is misleading.
ls
(accepted answer) only lists one file per line on systems that have been configured to do so. All others, fit multiple files into each line, it also doesn't list hidden files. To match the prompt, the command should be ls -la
(or -al
if you prefer). Also ls -lah
should be accepted since it's commonly used and fits the criteria.
The real problem here is that there's only one file. And of course that ls is configure to print one per line by default on the machine.
I fell foul of this too.