News for hackers. Stuff that matters.
Re:Show HN: Memorize Terminal Commands by jclulow on Sunday July 28, 2019 @08:41PM (#20550658)

    Your answer:
    ls -lha

    Correct answer:
    ls -lah
Oh dear.
Re:Show HN: Memorize Terminal Commands by maherdeeb on Monday July 29, 2019 @01:58AM (#20551837)
there 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
Re:Show HN: Memorize Terminal Commands by pm7 on Monday July 29, 2019 @02:33PM (#20557787)
Why 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 ~
Re:Show HN: Memorize Terminal Commands by mimimi31 on Monday July 29, 2019 @11:21AM (#20555489)
Question: 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'

Re:Show HN: Memorize Terminal Commands by BanazirGalbasi on Monday July 29, 2019 @01:53PM (#20557320)
I 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

Re:Show HN: Memorize Terminal Commands by Pawamoy on Monday July 29, 2019 @04:22PM (#20558970)
echo -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

Re:Show HN: Memorize Terminal Commands by ilikepi on Sunday July 28, 2019 @09:16PM (#20550783)
I 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.
Re:Show HN: Memorize Terminal Commands by jclulow on Sunday July 28, 2019 @09:18PM (#20550795)
I 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.
Re:Show HN: Memorize Terminal Commands by TheDong on Monday July 29, 2019 @12:50AM (#20551597)
Not 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.

Re:Show HN: Memorize Terminal Commands by darrenf on Monday July 29, 2019 @02:35AM (#20551987)
> 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.

Re:Show HN: Memorize Terminal Commands by icebraining on Monday July 29, 2019 @08:19AM (#20553741)
> 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/...

Re:Show HN: Memorize Terminal Commands by mikorym on Monday July 29, 2019 @01:22AM (#20551710)
You can just put the flags in a set and test for set equality.
Re:Show HN: Memorize Terminal Commands by archon810 on Monday July 29, 2019 @01:29AM (#20551736)
I 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

Re:Show HN: Memorize Terminal Commands by oars on Monday July 29, 2019 @07:01AM (#20553242)
This is what is supposed to happen. UNIX-based terminals are case sensitive.
Re:Show HN: Memorize Terminal Commands by lol768 on Monday July 29, 2019 @10:51AM (#20555174)
Site dev should still be able to turn off the autocomplete functionality?
Re:Show HN: Memorize Terminal Commands by bitwize on Monday July 29, 2019 @11:25AM (#20555536)
It'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".
Re:Show HN: Memorize Terminal Commands by jclulow on Monday July 29, 2019 @04:14PM (#20558876)
But 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.