Latest Updates: bsd

  • Command Help using Manual Pages (man) (OS X, Linux, BSD)

    20:42 on July 27, 2009 | 0 Comments Tweet This! | Digg This!
    Tags: bsd, , ,

    As you start using the command line, you’ll come across thousands of different commands, all with their own options and ways of taking options.  Every command is different, but help is on hand in the form of man pages.

    Manual Pages (or man page for short) are the documentation distributed with every command (or, at least, should be with every command) which tells you how a particular command works.

    From a Terminal in OS X, Linux, or BSD, you should have access to a command called man.  man is the reader for these man pages, and parses them nicely onto the screen for you.

    So, for example, if you wanted help with the mount command, you would simply do:

    man mount

    … and you would be presented with the manual page for mount.

    This is true of any command, and there should always be a manpage with the command. It’s good practice to do this as a developer, but you may find cases where people don’t.

    There are also various web sites which have html versions of these manpages, and you can normally find these on the Linux or BSD distribution’s site you are using, or the Apple site.  For the sake of this post, the three below are for Ubuntu, FreeBSD, and OS X.

    Ubuntu - http://manpages.ubuntu.com/

    FreeBSD – http://www.freebsd.org/cgi/man.cgi

    OS X – http://developer.apple.com/documentation/Darwin/Reference/ManPages/

    So the next time you need help with a particular command, do a quick man thecommand and hopefully, you’ll have all the help you need!

     
  • Count the Number of Words in a Text File (OSX, Linux, BSD)

    23:43 on July 25, 2009 | 0 Comments Tweet This! | Digg This!
    Tags: bsd, , ,

    Say you have a text file,  and you want to know either how many lines are in the file, how many words are in the file, or how many characters are in the file.

    How can you do that?  Counting them manually would take way too long.  This is where wc comes in!

    The wc manpage (this is the Ubuntu manpage) shows the options, but using it is simple from a terminal:

    Count the number of lines:

    wc -l filename.txt

    Count the number of words:

    wc -w filename.txt

    Count the number of characters:

    wc -m filename.txt

    That will give a basic look at the number of lines, words, or characters of the supplied text file – there are many other small command line utilities which can be used in conjunction with wc to do all sorts of clever things, and I hope to produce further posts on these in the near future.

     
  • Vim Text Editor: Guides on how to use it

    15:09 on July 18, 2009 | 1 Comments Tweet This! | Digg This!
    Tags: bsd, , ,

    New users to Linux or BSD, will have no doubt come across Vim (or at least Vi). Vim is “Vi IMproved” – it’s simply an extended Vi.

    You’ll have probably had times when you need to do something very simple, such as Cut and Paste, and not been able to, just because you don’t know how.  You’ve also then resorted to using the window manager cut and paste, and relying on that (which does work, but isn’t very “Vim”!)

    I use Vim a lot, yet I still only use some very very basic commands, which isn’t ideal, nor is it very productive, although I do get by.

    I, probably like you, want to learn how to use Vim properly, so went in search for some good help.

    @peteog pointed me towards a couple of resources, that after looking at them, seem extremely good and easy to follow.  I’ve certainly started using some of the things on them.

    The first resource is “Vim Recipes” found here:  http://vim.runpaint.org.  Vim Recipes is an online cookbook, and of course, a free resource.  I highly recommend you go through the book online, or download the PDF.

    The second resource, which may even find it’s way into a frame and on my wall, is: http://www.viemu.com/vi-vim-cheat-sheet.gif – this is a great piece of reference material you can have nearby, so whilst you’re using Vim, you can have a quick glance over if you need a particular feature.

    Hopefully with those two resources, we’ll be well on our way to being better Vim users!  Please let me know in the comments of any other good resources you may have or have used in the past!