官术网_书友最值得收藏!

Getting help with Bash

Sometimes in technical books, people skip the Getting help heading. Don't skip this one! It's very important, and will save you a lot of time and confusion.

You can get help on using most of the commands in this book with a two-step process. When you're using Bash, to get help on a command named printf, use help first:

bash$ help printf

You'll get some help output, so you now know that printf is a Bash keyword or builtin. That's the version of the command you want help with, because that's the one that you'll be using when you call it from within Bash.

To see why this is confusing, try the man manual reader command, instead:

bash$ man printf

You'll get a completely different document, a full manual page! The features aren't even the same! What's going on?

In a shell script, the same command can have more than one implementation. In Bash, you can see a list of all of them using the type command with its -a (all) switch:

bash$ type -a printf
printf is a shell builtin
printf is /usr/bin/printf

Notice how there are two results for printf: the first is a shell builtin  a part of Bash itself  and the second is a program on your filesystem. They will behave differently and have different documentation. We'll see more of the type command in later chapters.

So remember: always try help first! Some people use Bash for many years before learning it exists, and wonder why the man pages are always wrong. You can see a full list of available help topics by typing it on its own, with no arguments:

bash$ help
主站蜘蛛池模板: 理塘县| 汽车| 宁都县| 昔阳县| 全州县| 千阳县| 安康市| 泽库县| 博野县| 溧水县| 安图县| 泗洪县| 汉沽区| 连江县| 忻城县| 大余县| 津市市| 四平市| 林口县| 永平县| 衡南县| 新干县| 静海县| 北碚区| 信宜市| 利辛县| 寿阳县| 唐河县| 乌拉特前旗| 盱眙县| 英吉沙县| 封开县| 涟水县| 申扎县| 海丰县| 法库县| 冷水江市| 高邮市| 札达县| 葫芦岛市| 定边县|