5 ms·
Your answer: ls -lha Correct answer: ls -lah Oh dear.
by jclulow 7y ago
Your answer:
ls -lha
Correct answer:
ls -lah
Oh dear.
- ilikepi 7y agoI got bit by that as well. I think testing common arguments is useful, but I wonder if it would make more sense to limit to a single argument. That would eliminate the need to handle permutations, and it would also keep the questions simpler.
- jclulow 7y agoI think to do this properly you need to implement the argument parsing the command is doing; e.g., use getopt(3C). After all, "ls -la -h --" is valid too.
- TheDong 7y agoNot all unix utilities use getopt. Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected. For things like the pager questions, it'll need to implement a full vte and vte comparison, so that should be fun. For bonus points, one of the options to emulate linux in the browser could be used to do that more securely and without the need for a service... though the load time might increase by several minutes or hours.
- darrenf 7y ago> Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected. I'm not sure it is clearly correct. Some commands don't produce output, `mkdir` and `cd` for example (the first two in the animation). Furthermore they'd have to blacklist `echo` and other ways to produce the output against the spirit of the exercise... until an answer is, say, `echo $?` - at which point you'd require a preceding command exiting in a suitable way in order to keep the "just execute it" approach workable.
- icebraining 7y ago> though the load time might increase by several minutes or hours. Just a few seconds on my humble E480 using Firefox: https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/buildroot-x86.cfg https://bellard.org/jslinux/vm.html?url=https://bellard.org/...
- mikorym 7y agoYou can just put the flags in a set and test for set equality.
- archon810 7y agoI got hit by auto correct on my phone and answered like this: Question: Write the command that clears the terminal-command line screen and shows it as new Your answer:Clear Correct answer:clear
- maherdeeb 7y agothere is also ls -lh -a, ls -l -a -h and so on. I am going to solve this by adding an option in the future to activate the regex if the user doesn't want to memorize a single pattern. Thanks a lot for mentioning it. Regards
- pm7 7y agoWhy not do it by default? Why do you believe you can choose one "right" pattern? Also: Questions repeated multiple time within single session. Question: Write the command that clears the terminal command line screen and shows it as new Your answer: reset Correct answer: clear "Clear" will not fix terminal in some cases. Maybe do not ask for "and shows it as new" and note you only want to remove current text? Question: Write the command that you use to move into your home directory '~' Your answer: cd Correct answer: cd ~
- mimimi31 7y agoQuestion: Write the name of the standard subdirectory of the root directory which contains references and files for the devices. Your answer: dev Correct answer: /dev Edit: Also Question: Write the command that shows a text 'hello world' in the console without moving to a new line after executing the command Your answer: printf '%s' 'hello world' Correct answer: echo -n 'hello world'
- BanazirGalbasi 7y agoI also got a similar result with this: Question: Write the command that reads the file that has the name (text.txt) and shows only one page each time you hit space and it allows you to explore the file back and forward. Your answer: less test.txt Correct answer: less text.txt
- Pawamoy 7y agoecho -n hello world considered wrong as well. Also Question: Write the command that you use if you finish working with the terminal and you want to log out from the current session. Your answer:logout Correct answer:exit
- bitwize 7y agoIt's practice for your interview skills. If you're on a job interview, and you say 'ls -lha' when the interviewer is expecting 'ls -lah', chances are good you will be marked wrong, and may be passed over in favor of a candidate with "stronger command line skills".
- jclulow 7y agoBut neither of those options is more or less correct than the other; there is no way to know which a strict (but apparently unqualified!) interviewer is going to prefer.