Introduction to Bash, VIM & Regex

Documentation and Options

Introduction to Bash, VIM & Regex

Check out a free preview of the full Introduction to Bash, VIM & Regex course

The "Documentation and Options" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:

To find the documentation at any time, James shows the man command that lists the commands that are available in the shell. Afterward, he demonstrates that options also called flags or switches, which are special arguments that can be passed onto shell command.

Preview
Close

Transcript from the "Documentation and Options" Lesson

[00:00:00]
>> James Halliday: And again, I already mentioned this, but if you wanna learn more about the different arguments that the wc command takes, you can type man space wc. And you can read all about it. So here's, it's kind of written in a very reference oriented way. There aren't too many options for the wc command, but that's what they are.

[00:00:33]
>> James Halliday: Okay, so we've been using these things, flags or switches or options or arguments a while for a little bit. But it's important to know kind of how they usually work. But it's sort of up to every program to implement these conventions. Mostly the programs do implement the standard conventions but sometimes they do something in a different way.

[00:00:59]
And you kind of just have to read the documentation for every program to know specifically how it works but generally speaking, these conventions tend to hold. So one of these conventions is that you can generally speaking, move the arguments around. So I can do wc -l, in a file, or I can put that -l at the end, and these mean the same thing.

[00:01:31]
>> James Halliday: Generally speaking, the order of the arguments doesn't matter. Some commands, some programs, take flags that expect values. So head is an example of a program that will print out the first, by default, I think the first ten characters from the file. So if I run head on this file, I see the little blurb from Project Gutenberg that they stick at the front of this text file.

[00:02:04]
So that's ten lines. But if I want a different number of lines, I can do -n5 and I get five lines. You can also specify. You can do -n5, which usually works but not always, or sometimes you have to do -n space 5. Or sometimes for longer options, especially ones with dash dash.

[00:02:30]
So if I read the page for man, so I can see that lines are -n is an alias for --lines. And when you pass in --lines, you have to put an equal sign afterward. So if I do head --lines=5, then it works like that. So these all mean the same thing.

[00:02:54]
>> James Halliday: And again, I can move that --lines to be before or after the file name. The order usually doesn't matter, although sometimes it does.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now