[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: chmod + chown



> w00t.  i was thinking find was more like the find.exe from dos/win32.

The linux upgrade for that function is a program called 'grep'.

The funny name comes from the syntax used in the earliest text editor for *nix,
simply named 'ex' (for 'external editor').

The syntax of the command to search for text in that editor was to specify the
range of lines in which you were searching (the 'g' is a shorthand for "global",
meaning from the first to the last line), followed by a "regular expression"
(where the 're' comes from), which is a pattern for what you're looking for, and
finished off with an editor command for what you want to do when it finds a line
that matches the "regular expression", in this case, we just want it to 'print'
the matching line (and hence the trailing 'p').

Put that all together and you get 'g/re/p'. It was so useful, it became a
standalone command, and the regular expressions are quite, well, expressive.

REs, or RegExes, are a special syntax to describe text that matches a pattern,
similar to the way certain characters match filenames in the shell. However, the
shell filename expansion syntax is very different than regular expression syntax.

In the shell, filename that start with 'A', 'B', or 'c', and end with '.txt'
would be specified as '[ABc]*.txt' on a command line.

In a text editor, or for the 'grep' command, the same match would be expressed
as '^[ABc].*\.txt$' where we are indicating the line must consist only of such
'words'. The '^' matches the "beginning" of the line, the '$' matches the "end"
of the line, and the '.' matches "any" character. The '*' matches 0 or more of
whatever the previous character was, in this case "any" character. Finally,
because we want to actually match the '.' character, we have to mark it so that
it no longer has its special meaning of the "any" character. To do that you put
a '\' (backslash) in front of any character that would normally be special to
make it no longer have its special, magical properties.

And that, in a nutshell, is 'grep'.

I don't know if there's anything there, but there's a Kwiki with all sorts of
'Linux-By-Example' commands at http://www.archlug.org/lbe

See http://www.archlug.org/linux-by-example/LBE-grep
and http://www.archlug.org/linux-by-example/LBE-find

Mike/

---------------------------------------------
http://www.valuenet.net



-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.