LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: jessew

GNU 1.0

[复制链接]
发表于 2003-12-12 16:43:49 | 显示全部楼层
我现在上班都用Linux了
发表于 2003-12-13 23:15:16 | 显示全部楼层
我早就想装HURD了,前几天在gnu网站上找了大半天,也没找到在哪里下在安装包,从源代码编译有没找到详细的文档,不知道在什么环境下用什么工具编译。奇怪的很,官方网页上指向hurd安装包的连接都不能用,debian主页上也没找到hurd安装盘的下载
发表于 2003-12-14 00:58:27 | 显示全部楼层
Hurd-K5 CD-Images:
ftp://ftp.gnuab.org/pub/gnu/isos/
基本上,K5只需要下前两个iso就够了,详见README-K5
发表于 2003-12-14 01:04:11 | 显示全部楼层
谢谢,正在下载
发表于 2003-12-14 01:06:22 | 显示全部楼层
发表于 2003-12-14 01:23:22 | 显示全部楼层
以后如果要找最新的hurd iso image,请到debian-hurd mailing list
中查找Philip Charles同志的贴子,大概每八至九周出一个新版本。
发表于 2003-12-14 11:30:18 | 显示全部楼层
气死了,本来翻译的using_gnuhurd的内容,现在又全没了,一个事先没有通知的断电把我几个星期的工作全费了,现在文件根本打不开,原来的备份又太老,看来这个寒假之后才能出来了,哈哈哈哈哈哈哈,天啊,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
发表于 2003-12-14 12:26:00 | 显示全部楼层
Shutdown
关机

   You can shut down or reboot your GNU/Hurd machine by typing these
commands:
  你可以输入这些命令关闭和重启你的GNU/Hurd机器:
     bash-2.05# reboot <ENTER>

     bash-2.05# halt <ENTER>
   In a matter of seconds it should tell you that it is in a type
loop and pressing <ctrl>, <alt>, and <Delete> at the same time will
make the system reboot.  It is now safe to shut the computer off.
  数秒后它会告诉你它正在循环中,同时按住 <ctrl>, <alt>, 和<Delete>键会重启系统.现在你可以安全关闭计算机.
Using
使用

   Now that you have GNU/Hurd installed and booting, you're probably wondering "What can I do with it?"  Well, GNU/Hurd is capable of being a console based workstation.  The X Window System is known to work, but is not required in order to learn how to use GNU/Hurd. This chapter is intended to get you acquainted to the "command line" of GNU/Hurd.  You should read the Hurd FAQ and also have a working knowledge of "Bash", the GNU shell.  If you are not familiar with this material, you can read *note The Shell:: for a brief introduction.
现在你已经安装并启动了GNU/Hurd,你可能想知道”我可以用它干什么?”是的,GNU/Hurd适合于作为一个基于控制台的工作站.X Window系统已知是可以工作的,但是要学习如何使用GNU/HURD并不需要它这一章目的是使你认识GNU/Hurd的”命令行”.你应该阅读Hurd FAQ,并且有实用的”Bash”,GNU shell的知识.如果你并不熟悉这些材料,你可以阅读*note The Shell::得到简明的介绍.

The Shell
=========
Shell
   If you successfully installed GNU/Hurd and you are in multi-user mode, you should have a login shell ready for you, which should look like this:
  如果你成功的安装了GNU/Hurd并且你现在在多用户模式,你应该有一个登陆的shell在你的面前,看起来像这样:

     GNU 0.3 (hurd)
     
     Most of the programs included with the Debian GNU/Hurd system are
     freely redistributable; the exact distribution terms for each program
     are described in the individual files in /usr/share/doc/*/copyright
     
     Debian GNU/Hurd comes with ABSOLUTELY NO WARRANTY, to the extent
     permitted by applicable law.
     login>
     
     Type Login:USER or type HELP

   You can go ahead and type `login root'<<ENTER>> to get started.
   你可以直接接下去输入'login root'<<ENTER>开始.
   What you need to know for using GNU/Hurd is your basic Unix-like commands.  The GNU Project has written a replacement for almost every Unix command.  You need to learn how to copy, move, view, and modify files.  It also is important to learn one of the many editors that are available for GNU/Hurd.  The default editor is Nano, which is very simple and self explanatory yet not as powerful as Emacs or vi. It is there because it's small, and easy on the memory of your computer.  I am not going to cover it here because it is quite self-explanatory.  This section hopes to get you started with these necessity commands.  If you have knowledge of these already, you can probably skip ahead.  Also, you might want to get comfortable with the default editor first, then come back to this section to learn your basic GNU/Hurd shell commands.
  你需要知道的对GNU/Hurd的基本知识是基本的Unix 类命令.GNU工程写了几乎每一个Unix命令的替代品.你需要学习如何复制,移动,查看和修改文件.学习存在于GNU/Hurd中的可用的许多编辑器中的一个也是很重要的.缺省的编辑器是Nano,一个非常简单的自解释的但是还不像Emacs或者vi那样强大的编辑器.它的存在是因为它的小,和容易在你计算机的内存中存在.我不会在这里解释它因为它自己解释自己了.这一节希望使得你从一些必须的命令开始.如果你已经具备这些知识,你可以直接跳过.当然,你也许想先熟悉一下缺省的编辑器,然后回到这一节来学习你的基本的GNU/Hurdshell命令.
   The shell is the the program that interacts with the filesystem and the data on the filesystem.  This is called bash (Bourne again shell)(1).  Once you get comfortable with the shell, you can happily sit at any Unix-like workstation and get some work done.  It is very important that you get comfortable with the shell.  It is also called the terminal, console, etc.  At this prompt you should be ready to begin.  (Note: Shell variables cause your prompt to display your current working directory.  Your prompt may look like this: "user@hurd:~/$".)
  shell是一个和文件系统及文件系统上的数据打交道的程序.这个叫做bash (Bourne again shell)(1).一旦你熟悉了shell,你可以快活的坐在任何类Unix工作站的面前完成你的工作.熟悉shell是很重要的.它也叫做终端,控制台等等.在这个提示面前你已经可以开始了.(注意:shell使得你的提示符显示你的当前工作目录.你的提示符也许看起来这样"user@hurd:~/$".)
     bash-2.05$

   To make a directory for yourself, you would use the `mkdir' (make directory) command.  You can make as many as you want as long as they are in your home directory.
  要创建你自己的目录,你会使用'mkdir'(make derectory创建目录)命令.你可以在你的home目录创建你想的多的数不胜数的,并且长度无限的目录.
   You may notice that many commands are abbreviations. The tradition of Unix-like systems dictates that commands take this form. Since the user is expected to type many commands into the shell, the commands are kept succinct so that fewer keystrokes are required. The side effect, of course, is many command names that are confusing at first sssight.
  你也许注意到许多的命令是缩写的.传统的Unix类系统指定命令使用这种格式.由于用户会输入许多的命令到shell,命令保持整洁所以少的按键是必须的.副面影响是,当然,许多的命令名第一眼看上去令人迷惑.
     bash-2.05$ mkdir docs tmp sources <ENTER>

   To change directories you would use the `cd' (change directory) command.  One thing to remember is that wherever you are in the filesytem, typing `cd' alone will put you back in your home directory.  (Note:_The bash shell features command line completion, by pressing the first letter of the file or directory plus <<TAB>> will do this._)
  要改变目录你会使用'cd'(change direcrory改变目录)命令.要记住的一件事是不论你在文件系统的任何地方,只输入'cd'会把你放到你的home目录(注意:_bash shell自动完成的特性,通过输入文件或者目录的第一个字母并按<<TAB>>键会实现这个.)
     bash-2.05$ cd /usr/local <ENTER> #this puts you in the /usr/local directory.
     bash-2.05$ cd <ENTER>            #this puts you back in the home directory.

   There is another short cut, ` cd ../' This puts you in the directory above the one you're currently in.
   还有另一个快捷方式,'cd ../'这会把你放到当前所在目录的上一层目录.
   There are many ways to view a file, but we'll use the most common command called `cat' (2).
   有许多的方式可以查看一个文件,但是我们会使用最普遍的叫'cat'的命令.
     bash-2.05$ cat README | less <ENTER>

   You may wonder what ` | less' means. We use the | (pipe symbol) to take the output of `README' and feed it to the `less' command. `less' allows you to view the documents one screen at a time and it allows you to go back to the beginning of the document.  You have to type <q> to quit `less'.
  你也许想知道'|less'是什么意思.我们使用|(管道符号)取得'README'的输出并送到'less'命令的输入.'less'允许你一次一屏的查看文档,它也允许你回到文档的开头.你需要输入<q>以退出'less'.
   To copy a file from one place to another you use the `cp' (copy) command.  The `cp' command has many options such as `cp -f -v -r'. Luckily for us, the `info ' command will clarify many of the confusing commands and all three options.
  要从一个地方复制文件到另一个地方你可以使用'cp'(copy复制)命令.'cp'命令有许多选项像'cp -f -v -r'.幸运的是,'info'命令澄清许多令人迷惑的命令和所有选项.
Typing,
输入,

     bash-2.05$ cp README chapter1.txt foo1/ <ENTER>

   will copy `README' and `chapter1.txt' to the `foo1' directory. Here are a few good options to remember:
   会把'README'文件和'chapter1.txt'到'fool'目录.这里有几个需要记住的好的选项:
发表于 2003-12-14 18:04:33 | 显示全部楼层
bash-2.05$ cp -rfv foo1/ file2.txt tmp/ <ENTER>
     bash-2.05$ cp -rf /cdrom/* ~/ <ENTER>

   The `-r' means "recursive", so `file2.txt', the `foo1' directory, and all the contents of `foo1' are copied to the `tmp' directory. The `-f' means "force", I have a habit of forcing things.  The `-v' means "verbose", It will show you on the screen what files are being copied.  In the second example, we have this `~/', which is a short cut representing your home directory.  So that command would copy the contents of `/cdrom' to your home directory.(Note:_The asterik symbol '*' is called a wildcard character which means "anything"_.)
   '-r'意思是”recursive循环”这样'file2.txt','fool'目录和'fool'的所有内容都复制到'tmp'目录.'-f'意思是”force强制”,我有一个强制执行的习惯.'-v'意思是”verbose详述”,它会在屏幕上显示什么文件正在被复制.在第二个例子中,我们有这个东西'~/'一个代表你的home目录的快捷方式.这样命令会复制'/cdrom'的所内容到你的home目录.(注意:_符号'*'叫做通配符,意思是”任何东西”_)
   To rename or move a file or directory you would use the `mv' (move) command.  Be careful, because `mv' is a very powerful command.  You can lose data if you're not careful about what you do.  To rename a file or directory you would type, for example:
   要重命名和移动一个文件或者目录你会用到'mv'(move移动)命令.小心,因为'mv'是一个功能非常强大的命令.你如果对你做的事情不在意的话你会丢失你的数据.要重命名一个文件或者目录你会输入,例如:
     bash-2.05$ mv foo1/ foo2 <ENTER>

   Now you no longer have a `foo1' directory, it's called `foo2' now. The same thing can be done with plain files, too.
   现在你不再有一个'fool'目录了,他现在叫做'foo2'.同样的事情可以对无格式的文件进行操作.
   I'll bet you're saying, "I'm doing all this work, but how do I view my directories?"  You answer would be the `ls' (list)command. The `ls' command also has many options.
   我打赌你在说,”我在做所有的工作,但是我怎么查看我的目录呢?”你的答案会是'ls'(list)命令.'ls'命令也有许多选项.
     bash-2.05$ ls -al <ENTER>

   The two options I have here are used more often than any others. The `-a' will show us all hidden files in the current directory.(3) The `-l' option tells us to display the directory in long format. This means it shows us the date modified, file size, file attributes, etc. of all files.
  这里我给的两个选项比任何别的选项使用的更频繁.'-a'会显示所有当前目录(3)下的隐藏文件.'-l'选项告诉我们以长格式显示目录.这意味着它显示数据的修改,文件大小,文件属性,所有的文件.
   A user will also notice that there are files with dots in front of some files in thier home directory.  The dotted files are typically hidden configuration files. The user will also notice a dot, followed by two dots. In the unix file system a dot represents the current directory. The two dots represent the directory above your current working directory. Examples of using these dots are common in building software.
  用户也会注意到在他们的home目录下有一些前面带着点号的文件.这些带点号的文件是典型的隐藏的配置文件.用户也会注意到一个点号,跟着是两个点号.在unix文件系统里一个点号代表当前目录.两个点代表你当前目录的上一层目录.使用这些点号的例子常见于编译文件时.
     bash-2.05# ../configure # This runs configure from the directory above.
     bash-2.05# ./program    # This runs program from current directory.

   Now that you have made all this mess in your home directory, I'll bet you're wondering how you can get rid of things.  There are two important deleting commands.  The `rm' (remove) command is convienent for removing files.  `rm' command can also remove directorys that the `rmdir' command can't. I'll show the you a basic `rm' example, then my favorite with the extra options.  The `rmdir' command will only delete directories that are empty.
  既然你已经把你的home目录给搞乱了,我会打赌你想知道如何处理他们.有两个重要的删除命令.'rm'(删除)命令适合删除文件'rm'命令也可以删除那些'rmdir'命令无法删除的目录我会展示一个基本的'rm'命令的例子,然后我会加上一些额外的选项.'rmdir'命令会仅仅删除空的目录.
     bash-2.05$ rm README <ENTER>

   Now, `rm' with some options:
   现在,'rm'跟着一些选项:
     bash-2.05$ rm -rf foo2/ <ENTER>

   The second example is very powerful.  The `-r' means "recursive" and the -f means "force."  This removes all the contents of `foo2', without prompting the user for confirmation.
  第二个例子功能十分强大.'-r'意思是”recursive循环”而-f意思是”force强制”这会移除'foo2'的所有内容,而不提示用户确认.
   These are only the basic commands to get you started... there are many, many two- and three-letter commands.  The more you use GNU/Hurd, the more options and commands you'll learn.  The more you learn, the more freedom you'll have.And that is a very valuable thing.
   这些仅仅是你开始的基本命令...还有很多很多的两个和三个字母的命令.你使用GNU/Hurd越多,你学到的命令和选项就会越多.你学的越多,你就会有更多的自由.(享受自由的能力提高了).这是非常有价值的事情.
    Now that you have been cruising around your filesystem, you might be wondering how much space you have left on your drive.  There is a simple command to check this:
   既然你已经漫游了一遍你的文件系统.一可能会想知道你的磁盘还有多大的空间.这里有简单的命令来做这个检查:
     bash-2.05$ df / <ENTER>
     Filesystem           1k-blocks      Used Available Use% Mounted on
     /dev/hd0s1            1920748   1203996    619180  67% /

   If you don't put a directory after the command such as `/' or `/home', the `df' (diskfree) command will spit out some errors.
   如果你把像'/'或者'/home'的目录放到命令后,'df'(diskfree磁盘空余)命令会弹出一些错误.
   If your prompt is not telling you what directory you are in, you can use the `pwd' (present working directory) command:
  如果你的提示符不告诉你当前正在的目录,你可以使用'pwd'(present working directory当前工作目录)命令:
     bash-2.05$ pwd <ENTER>
     /usr/src

   As a final note, always remember: _`info' is your friend on GNU/Hurd._
   作为最后的笔记,时时记住._'info'在你的GNU/Hurd是你的朋友.
   ---------- Footnotes ----------
    脚注
   (1) This is a pun on the name of the original Unix shell, the Bourne shell, and the Christian idea of being "born again".
   (1)这是一个关于初始的Unix shell的双关语, the Bourne shell,和基督教的意思”重生”
   (2) An abbreviation for _concatenate_, since `cat' can be used to concatenate files.
   (2)_concatenate_连接的另一个缩写,因为'cat'可以用来连接文件
   (3) Important files are often hidden, to prevent the user from accidentally deleting them.
   (3)重要的文件常常隐藏,防止用户不小心删了它们.
Standard Input and Output
=========================
标准输入输出
   Computers borrow many concepts from mathematics.  One very important concept that will be familiar to those with a background in programming is the idea of a _function_.  Informally, the term _function_ encapsulates the following idea:
  计算机从数学中带来了许多的概念.其中一个非常重要的对于那些有编程背景的人来说熟悉的概念是_function_(函数),通常来说,术语_function_封装了以下的思想:
         *When you put something in, you get something out.*
         *当你放一些东西进去的时候,你会从里面拿出一些东西来*
  Let's look at some examples of functions:
  让我们看一些函数的例子:
  1. In math classes, students draw graphs of functions, such as y =
     x^2.  In this case, you put in x, and you get x^2; for example,
     if you put in 3, you get 9.
  1.在数学课上,学生们画函数的图像,像y=x^2.这样,你放进去x,得到了x^2;例如,如果你放进去3,你得到9.
  2. A drink machine: you input a quantity of money and a drink
     selection, and the machine outputs a drink and your change.
  2.一个饮料机:你放入一定数量的钱和一个饮料的选择,机器输出饮料和你的零钱.
  3. Programming functions, such as _C_'s `isdigit()': you give it a
     character, and it returns 1 if the character is a digit, and 0
     otherwise.
3.程序的函数,像_C_的'isdigit()':你给它一个字符,它返回1如果字符是数字;不是的话返回0.
   There are many more examples of functions.  Notice from our examples that a function may have multiple inputs an outputs; however, a function must always produce the same output for any given set of inputs.  It would not do for a drink machine to sometimes give root beer when asked for iced tea!
  还有许许多多的函数的例子.注意我们的例子里一个函数可以有多个输入和输出;然而,一个函数必须常常对给出的任何一组输入产生一样的结果.不可能让机器某些时候根用户要一瓶冰红茶的时候给他一瓶啤酒.
   In GNU systems and other systems that follow the UNIX tradition, programs are functions.  Every program in a GNU system has a "standard input" and a "standard output".
  在GNU系统和别的跟随UNIX传统的系统,程序就是很多函数.一个GNU系统里的每一个程序有一个标准输入和标准输出.
   By default, a program's standard input comes from the command line, and its output goes to the terminal. For example:
  缺省的,一个程序的标准输入从命令行来,而它的输出到终端去.例如:
     $ echo "Echo prints whatever you type."
     Echo prints whatever you type.

We may "redirect" a program's standard output using the <>> key:
我们可以使用>”重定向”一个程序的标准输出:
     $ echo "Here's a quick way to write one-line files." > quickie.txt
     
     $ ls
     quickie.txt
     
     $ cat quickie.txt
     Here's a quick way to write one-line files.
     
     $ ls quickie.txt > dir.txt
     
     $ ls
     quickie.txt   dir.txt
     
     $ cat dir.txt
     quickie.txt

Similarly, we can use the <<> key to redirect a program's standard input:
类似的,我们可以使用<键重定向一个程序的标准输入:

     $ cat < dir.txt
     quickie.txt

We can use <>> and <<> together:
我们可以一起使用>和<.
     $ cat < dir.txt > copy.txt
     
     $ cat copy.txt
     quickie.txt

   Another property of functions that is useful to us is _composition_: we can make the output of one function the input of another.  When we use <|>, the pipe symbol, we are composing two functions; see *Note The Shell::. For example, we can pipe the output of the `info' program into `less', and scroll through a page:
   另一个实用的函数属性是_composition_(组合):我们可以使得一个函数的输出作为另一个函数的输入.当我们使用<|>,管道符号时我们在组合两个函数;另见*注意The Shell::.例如,我们可以把'info'程序的输出输到'less',并且通过页面来滚动:
     $ info gcc | less

   Understanding standard input and output, redirection, and pipes is fundamental to intermediate and advanced use of the GNU command shell.  Keep this section in mind while reading the rest of this manual.
   懂得标准输入输出,重定向,和管道对于GNU命令shell的中高就应用是基础.阅读这个手册的剩余的部分紧紧记住这一节.
Searching your Computer
=======================
搜索你的计算机
   Your computer is full of files.  Some of these files are your personal files; others, such as `/etc/passwd', are used by the system.  You may often want to find certain files on your computer, or find specific information in one or more files.  This searching could be done manually through many invocations of `cd', `ls', and `less'; however, repetitive tasks such as searching are the sort of jobs for which computers were invented, and your GNU system has several tools to make searching easier.
   你的计算机满是文件.这些文件的一些是你的个人文件;别的,像'/etc/passwd',是由系统使用的.你也许经常想要查找你计算机上特定的文件,或者在一个或者多个文件里的特定信息.这个搜索可以人工的通过许多对'cd','ls'和'less'的援用来完成.然而,重复的任务如这样的搜索是计算机发明来做的一种工作,你的GNU系统有许多这样的工具使搜索变得容易.
   The executables on your system are easy to find; simply use the `which' command:
   可执行文件在你的机器很容易找到;只是简简单单的使用'which'命令:
     $ which ls
     /usr/bin/ls

   The `which' command is especially useful when you have multiple copies of a program, each at a different location in your filesystem, since it allows you to find out which is executed by default.  For example, if I install one version of Mozilla using Debian's `apt-get' command, and another version by downloading the source from `http://www.mozilla.org' and compiling it, I can type `which mozilla' to find out which is executed by default.
  'which'命令在你有许多同一程序的copies,每一个在你的文件系统的不同位置的时候尤其有用,因为它允许你查找哪一个可执行程序是缺省的.例如,如果我用Debian的'apt-get'命令安装了一个版本的Mozilla,另外一个版本是通过从 `http://www.mozilla.org' 现在源代码和编译它得到的,我可以输入'which mozilla'来找出哪一个缺省执行.
   Your GNU system's more general searching tools are:
  你的GNU系统更通用的搜索工具有这些:
   * `locate'

   * `find'

   * `grep'

   * `xargs'
发表于 2003-12-14 20:52:04 | 显示全部楼层
Of all these programs, `locate' is the simplest.  `locate' searches through a database for files whose names match the pattern passed to it on the command line.  For example, typing `locate bash' would print out a list of all files for which "bash" is part of the file's name.
   在所有这些程序中,'locale'是最简单的.'locale'搜索一个包含与在命令行上传递给它的文件名相符的文件的数据库.例如,输入'locale bash'会打印出所有”bash”是其文件名一部分的文件的清单.
   Since `locate' searches through a database instead of an actual filesystem, it runs very quickly.  Building this database, however, takes a relatively-long time.  The superuser (root) can rebuild `locate''s database by typing `updatedb'; if you try to use the `locate', and it gives an error message mentioning the databse, you probably have to run `updatedb'.
  因为'locale从头到尾搜索一个数据库而不是一个真实的文件系统,它运行的非常快.然而,创建这个数据库却耗费相当长的时间.超级用户(root)可以输入'updatedb'重建'locale'数据库;如果你尝试使用'locale',而它给出一个错误信息提到数据库,你也许需要运行'updatedb'.
   The `find' command is significantly more flexible than `locate', and therefore more complicated to use.  Since `find' searches through the filesystem instead of a database, it finds files more slowly than `locate' does.  `find' can find files based on such properties as file name, size, type, and owner, or any combination of these attributes.
   'find'命令显著的比'locale'更灵活,使用也更复杂.因为'find'命令由头至尾搜索文件系统而不是数据库,它查找文件的速度比'locale'所做的慢得多.'find'可以查找基于这些属性的文件,像文件名,大小类型和所有者,或者任何这些属性的组合.
   When invoking `find', you must tell it where to begin searching, and what criteria to use.  For example, to find all files whose names begin will the letter "b" in the current directory and all its subdirectories, you would type:
   当调用'find'时,必须告诉它从哪里开始搜索,使用何种标准.例如,要在当前目录和它的子目录下查找文件名以字母”b”开头的所有文件,你可以输入:
     $ find . -name 'b*'

   If my username is "tom" and I want to find all files in `/tmp' that belong to me, I would type:
   如果我的用户名是”tom”而我想查找'/tmp'目录下的所有属于我的文件,我会输入:
     $ find /tmp -user tom
     /tmp/.X11-unix
     /tmp/cvs610c01f0.1
     /tmp/cvs610c0d70.1
     /tmp/cvs610c8570.1
     /tmp/XWinrl.log

   I can also use conditions in combination; for example, I can search for files in `/tmp' that belong to me and begin with the string "cvs":
  在某些情况下我也会使用组合;例如,我可以在'/tmp'目录下搜索所有属于我的并且以字符串”cvs”开头的文件:
     $ find /tmp -user tom -name 'cvs*'
     /tmp/cvs610c01f0.1
     /tmp/cvs610c0d70.1
     /tmp/cvs610c8570.1

   We used the `find' command to find files matching given criteria.
To search the contents of one or more files, we can use the `grep'
command.(1)  `grep' is like a flexible, command line version of the
Search or Find dialogue boxes common in modern GUIs.
   我们使用'find'命令查找符合给定条件的文件.要查找一个或者多个文件的内容,我们使用'grep'命令(1)'grep'像一个封装在现在GUI上的搜索或者查找对话框的灵活的命令行的版本.
   The most basic way to use `grep' is to pass it a string, and a file in which to search for the string:
   最基础的使用'grep'的方式是传递它一个字符串,和一个要在其中查找字符串的文件:
     $ grep 'microkernel' faq.en.html
     <p>When we are referring to the microkernel, we say ``Mach'' and use it
     microkernel'' instead of just ``Mach''.
     <p>{NHW} If you are using the GNU Mach microkernel, you can set your

We can see that `grep' outputs the lines of the file `faq.en.html' that contained the string "microkernel".
我们可以看到'grep'输出了包含字符串”microkernel”的文件'faq.en.html上面的数行.
   We can also use a pipe to make `grep' search for a string in the output of another program:
  我们也可以用管道来使得'grep'搜索另外一个文件输出中的字符串
     $ echo "Mach is a microkernel" | grep 'microkernel'
     Mach is a microkernel

   The `xargs' command executes a command on each file in a list of files read from its standard input.  Most often, we redirect a list of files to `xargs'.  A very simple example would be:
    'xargs'命令在从它的标准输入中读取的列表中的每一个文件上执行同一个命令.更经常的是,我们重定向一个文件的列表到'xargs'.一个非常简单的例子会是:
     $ ls | xargs cat

This command would print the contents of all files in the current directory to the screen (do not do this on a directory containing many large files!).
这个命令会打印当前目录下的所有文件的内容到屏幕(不要在一个包括许多大文件的目录下做这件事!).
   A more useful application of the `xargs' command comes from combining it with `grep' to search for files based on their contents. For example, we can type:
   一个更有用的'xargs'命令的应用从它和'grep'的组合中来,把它和'grep'组合来基于其内容搜索文件.例如,我们可以输入:
     $ ls | xargs grep 'microkernel'

to search the current directory for files that contain the word "microkernel".  We can do more sophisticated searches by combining `find' with `xargs' and `grep'; for details, see *Note Contents: (find)Contents.
要在当前目录查找包含单词”microkernel”的文件.我们可以通过组合'find'和'xargs'以及'grep'来完成更复杂的搜索;要知道细节,请看*注意 目录find)目录.
   Note that in modern desktop environments such as GNOME, GUIs exist that let you search for files much more easily.  For the majority of users, these tools are sufficient.  The advantage of the command line-based tools discussed in this section is that their output can be redirected, and they can be used in shell scripts (*note Introduction to Scripting with Bash:.
  注意,在现代的桌面环境像GNOME,存在GUIs让你搜索文件更简单.对大多数的用户来说,这些工具就足够了.在这一节中讨论的命令行工具的好处就在于他们的输出可以重定向,他们可以在一个shell脚本里使用(*注意看 介绍和使用Bash脚本:.
   For more information on searching your computer, see *Note Overview: (find)Top.
   要得到更多关于在你的机器上搜索的信息,请看*Note 概述查找)主题.
   ---------- Footnotes ----------
    脚注
   (1) `grep' is an acronym; see *Note Usage: (grep)Usage.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表