Differences between version 11 and predecessor to the previous major change of CommandLine.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
| Newer page: | version 11 | Last edited on Friday, October 31, 2003 7:39:45 pm | by AristotlePagaltzis | Revert |
| Older page: | version 10 | Last edited on Tuesday, October 21, 2003 9:21:23 am | by JohnMcPherson | Revert |
@@ -1,16 +1,15 @@
-Unix's sheer power
is revealed through
the Command Line
.
+A CommandLine
is a program interface which
the user interacts with by entering commands as written text. The program then parses these commands and acts accordingly. Such an interface is usually highly scriptable - even if not intentionally so, but by virtue of redirection. When it is designed with scripting in mind, it is usually particularly powerful
.
-!!The command line is powerful
-
Most people think of the CommandLine
as a pain. Certainly under MicrosoftCorporation'
s OperatingSystem's its very limited and not very useful. However
to a seasoned Unix user, you can very quickly do almost anything. ThinkGeek
has a T-Shirt that says "Go away or I'll replace you
with a very small shell script". This is a play on
the fact that you can do anything at the command line
, including emulating irritating users. The Unix command line has hundreds
of programs,
and hundreds of ways of stringing them together
. cat
(1)
, grep(1)
, cut(1)
, awk(1), sed(1), find(1), wc(1), sort(1), uniq(1), test(1), ls(1), cd(1), ps(1), kill(1) are basically all
the major commands that users use, and yet that is enough to write pretty much any program. See TwoLetterCommands for a longer list of standard utilities
.
+In Unix, nearly all tasks can and should be done on the CommandLine.
Most people think of this
as a pain, but there are many features to make working on the CommandLine more convenient and therefor efficient
. Unix [Shell]
s are lightyears ahead in terms of usability compared
to the CommandLine interpreters MicrosoftCorporation
has delivered
with their [OperatingSystem]s in
the past
, although some
of the more basic (
and vital) conveniences such as TabCompletion have finally found their way into [Microsoft] CommandLine interpreters
. (You're 30 years late
, guys
, but hey
, welcome to
the party anyway
.)
-Almost every program has at least one CommandLine counterpart (eg: mozilla has wget(1), curl(1), w3c(1)
....)
+Do also note that a Unix system typically exposes its entire innards via means that are easily accessible from the [Shell] - much unlike any flavour of MicrosoftWindows
.
-!!The command line is arcane
-Well
, yes
, to people that aren
't used to it I guess it is. Thats what we are trying to help solve in this wiki by making information that
you need readily available
. Most people that have learnt
the Unix CommandLine are able
to do things on the command line far faster than people can do
it otherwise
.
+As well
, there is a large variety of small reusable tools to take care of common tasks (see TwoLetterCommands for a non-exhaustive list); taken together
, these provide the means
to write
''any'' program as a shell script, should
you be so inclined
. Doing so may not be not advisable for non-trivial tasks -
the [Shell]'s syntax lacks sufficiently powerful constructs
to express complex algorithms succintly. However,
it ''is'' possible
.
-apropos
(1) and man
(1) are your friends on the command line. Be prepared to do lots of reading (and selective ignoring) at first: Unix commands often have dozens of options that are seldom needed. The man
(1) command itself has 24 options! You don't have to memorize it all. If you've just read though the man pages a few times
, when you get into a situation where you need a particular command you will think "Ah! That's in the man pages somewhere!" and go
to look it up
.
+In fact, just about anything you do manually, possibly using a [GUI] application, can be done automatically with some counterpart for the CommandLine. (Web related tasks can be automated using wget
(1), curl
(1), w3m
(1), or others,
to name an example
.)
-See also [Shell]
and [CLI]
.
+Of course, all this power comes at a price: to the unitiated, the CommandLine is arcane
and scary. One way to address that is providing sources of information. This wiki is one of them; but you can get help right on the CommandLine using apropos(1) and man(1) as well. Be prepared to do lots of reading (and selective ignoring) at first: Unix commands often have dozens of options that are rarely used. The man(1) command itself has 24 options, yet you will almost never use any of them. Don't memorize them - just pick the parts you need and come back to the manpage again if you're missing something. This way you will acquire the common basics soon enough
.
-----
-One of
the best examples I can think of
is when you have a large set of files, and
you want to do something to only those files that have
some characteristic.
(Eg
rename/move/delete them). You use find(1) for this. The Windows "
Find Files"
dialog can give
you a list
of files that contain
a certain string
, and
that's all
. This also limits
you to documents containing plain text
.
+An example for
the CommandLine's power
is when you have a large set of files, which
you want to selectively perform
some action on
(eg
rename/move/delete some of
them). You can
use find(1) for this. (There are more ways, but find(1) is by far the most common.) This is a far cry from the ''
Find Files''
dialog in MicrosoftWindows, with which
you can only select files based on
a partial match
of their name without resorting to inspecting the
files' contents (and even then the options are limited). The resulting is just about useless for any other action than mass deletion, mass opening of files, or moving them all into a single directory. More complex actions, like directory structure preserving moves, simple rule based renaming, or anything else, is not supported by
that interface - you have to do the work manually.
+
+This is
a perfect example
, actually: [GUI]s can only be used to communicate intentions
that their designer had already thought of. It has been said that [GUI]s are much like picture books; and there
's a reason people stop using those back in grade one
. To express non-trivial concepts or intents
you need an actual lingual interface. And that is what the CommandLine is
.
