Live data from Hacker News

2013 Resolutions: a man page a day makes the newb go away

sobering.ca

41–49 of 49 posts

Re: 2013 Resolutions: a man page a day makes the newb go away

#41
One thing I'd love to see if you embark and stick to this new year's resolution is creating a blog post per man page with all the exercises and examples you tried out by applying what you've learned from each man page. It'd be great if each post included something like:

  (1) What is the command
  (2) What kinds of things you can accomplish with it 
      (i.e. why should I learn this command? how will 
      it benefit me)
  (3) Examples of the command applied by itself
  (4) Examples of the command applied in conjunction with
      commands you've previously written about via piping.

Re: 2013 Resolutions: a man page a day makes the newb go away

#43
post #5

How will you know which man page to read "next"?

So far the plan is to start with "man" and then go through the man pages of my most commonly used commands: cd, ls, grep, cat, sed, etc. After that, I may write a little shell script that simply opens one at random for me.

cd is a shell builtin, not a command, so there is no man page for it. There will be information about it in your shell's man page, though, which should be worth reading.

Re: 2013 Resolutions: a man page a day makes the newb go away

#44

One thing I'd love to see if you embark and stick to this new year's resolution is creating a blog post per man page with all the exercises and examples you tried out by applying what you've learned from each man page. It'd be great if each post included something like: (1) What is the command (2) What kinds of things you can accomplish with it (i.e. why should I learn this command? how will it benefit me) (3) Exampl…

That's what I had planned. Thanks for creating an outline for me. ;)

Re: 2013 Resolutions: a man page a day makes the newb go away

#45

One thing I'd love to see if you embark and stick to this new year's resolution is creating a blog post per man page with all the exercises and examples you tried out by applying what you've learned from each man page. It'd be great if each post included something like: (1) What is the command (2) What kinds of things you can accomplish with it (i.e. why should I learn this command? how will it benefit me) (3) Exampl…

That's what I had planned. Thanks for creating an outline for me. ;)

Also check out the many posts by catonmat (peteris krumins) about linux commands and scripting. I find that they are good examples of blog posts on how to use standard command line utilities.

Re: 2013 Resolutions: a man page a day makes the newb go away

#46
post #24

I hope this works out for you. I've taken up learning vim this year, but my main problem is forgetting the things I've learned. I tried cue cards but they fill up far too quickly; so my answer was to store my notes on a wiki: http://wiki.jbud.me/index.php?title=Vim

I second taking notes as you go, here are mines (from 2 years ago, in french): https://github.com/romainl/dotvim/wiki/Notes

Bram Moolenaar's seven habits has great insights about this subject: http://www.moolenaar.net/habits.html

Re: 2013 Resolutions: a man page a day makes the newb go away

#47

Earlier quoted context omitted.

Just found this little snippet via a quick Google search: dir="/bin"; man $(ls $dir |sed -n "$(echo $(( $RANDOM % $(ls $dir |wc -l | awk "{ print $1; }" ) + 1 )) )p") I think I may write my own version as well. Just to gain a bit more experience with shell scripting.

Unfortunately there are a couple of commands that don't have a man page, e.g. mpplu (from argyllcms-1.4.0-2.fc17.x86_64) or showchar (from psutils-1.17-38.fc17.x86_64).

I know the OP said he was a VIM guy, but here's my first approximation to a random manual page script for emacs; it doesn't strip out directories (like man1) or specify different sections of the manual, but it indexes manual pages, so you not only won't try opening pages for commands that don't have them, but you'll get other pages too (eg, the TCL library man pages):

  ;; Taken from http://emacswiki.org/emacs/ElispCookbook#toc57
  (defun directory-dirs (dir)
    "Find all directories in DIR."
    (unless (file-directory-p dir)
      (error "Not a directory `%s'" dir))
    (let ((dir (directory-file-name dir))
          (dirs '())
          (files (directory-files dir nil nil t)))
      (dolist (file files)
        (unless (member file '("." ".."))
          (let ((file (concat dir "/" file)))
            (when (file-directory-p file)
              (setq dirs (append (cons file
                                       (directory-dirs file))
                                 dirs))))))
      dirs))

  ;; Taken from
  ;; http://stackoverflow.com/questions/3815467/stripping-duplicate-elements-in-a-list-of-strings-in-elisp
  (defun strip-duplicates (list)
    (let ((new-list nil))
      (while list
        (when (and (car list) (not (member (car list) new-list)))
          (setq new-list (cons (car list) new-list)))
        (setq list (cdr list)))
      (nreverse new-list)))

  ;; Display a random manual page
  (defun open-random-man-page ()
    (interactive)
    ;; Get manual page paths from the environment.
    (setq man-paths (parse-colon-path (getenv "MANPATH")))
    (setq man-dirs ())
    (dolist (man-path man-paths)
      (setq man-dirs (append man-dirs (directory-dirs man-path))))

    ;; Get a list of files in manual page paths.
    (setq files ())
    (dolist (man-dir man-dirs)
      (setq files (append files (directory-files man-dir nil "^[^\.].*"))))

    ;; Fixup the files to be a list of man pages.
    (setq man-pages ())
    (dolist (file files)
      (setq man-pages (cons (car (split-string file "\\." t)) man-pages)))

    (setq man-pages (strip-duplicates man-pages))

    (random t)
    (man (nth (random (length man-pages)) man-pages)))
Be aware that Emacs lisp is still something I'm learning; I'm sure the above could be improved.

Re: 2013 Resolutions: a man page a day makes the newb go away

#48
post #5

How will you know which man page to read "next"?

So far the plan is to start with "man" and then go through the man pages of my most commonly used commands: cd, ls, grep, cat, sed, etc. After that, I may write a little shell script that simply opens one at random for me.

May I suggest:

* Read your primary shell's manpage.

* Read alternative shell's manpages. Most particularly zsh, if you're not already using it.

* Look at your bash history and most frequently used commands. Read those manpages.

* Read manpages of language(s) you're looking to develop in.

* Read manpages for tools that are supplanting existing tools. E.g.: ip(8) vs. ifconfig(8).

* Read manpages for not just commands (1 & 8) but file formats (section 5), special files (4), and system and library calls (2 & 3).

* Follow references in manpages (the "SEE ALSO" section(s).

* Try reversing the process. Use apropos to find tools which accomplish a given task.

* On Debian or Ubuntu, install the dwww package and surf manpages locally at http://localhost/dwww/man/ within your web browser.

Re: 2013 Resolutions: a man page a day makes the newb go away

#49

Earlier quoted context omitted.

Unfortunately there are a couple of commands that don't have a man page, e.g. mpplu (from argyllcms-1.4.0-2.fc17.x86_64) or showchar (from psutils-1.17-38.fc17.x86_64).

I know the OP said he was a VIM guy, but here's my first approximation to a random manual page script for emacs; it doesn't strip out directories (like man1) or specify different sections of the manual, but it indexes manual pages, so you not only won't try opening pages for commands that don't have them, but you'll get other pages too (eg, the TCL library man pages): ;; Taken from http://emacswiki.org/emacs/ElispCoo…

Another thing to consider: on my main Debian Linux box at home, this script finds roughly 20k man pages, which would take more than fifty years to read them all if you are reading one a day. Granted, I have tons of stuff installed, you could read more than one a day, reading a random one will lead to/make you aware of what's available on your system, etc, etc. Perhaps I should write up a blog post about this whole experience . . .
Post reply on HN