X


[ Pobierz całość w formacie PDF ]
.Whenever you are thinking Well, I have to do so-and-so onall those kind of les in my own partition", you have better think about using find.In a certainsense the fact that find nds les is just a side e ect: its real occupation is to evaluate.The basic structure of the command is as follows:find path.expression.115 116 CHAPTER 11.FUNNY COMMANDSThis at least on the GNU version; other version do not allow to specify more than one path, andbesides it is very uncommon the need to do such a thing.The rough explanation of the commandsyntax is rather simple: you say from where you want to start the search the path part; with GNUnd you can omit this and it will be taken as default the current directory., and which kind ofsearch you want to perform the expression part.The standard behavior of the command is a little tricky, so it's worth to note it.Let's supposethat in your home directory there is a directory called garbage, containing a le foobar.You happilytype find.-name foobar which as you can guess searches for les named foobar , and you obtain.nothing else than the prompt again.The trouble lies in the fact that find is by default a silentcommand; it just returns 0 if the search was completed with or without nding anything or anon-zero value if there had been some problem.This does not happen with the version you can ndon Linux, but it is useful to remember it anyway.11.1.2 ExpressionsThe expression part can be divided itself in four di erent groups of keywords: options, tests, actions,and operators.Each of them can return a true false value, together with a side e ect.The di erenceamong the groups is shown below.options a ect the overall operation of nd, rather than the processing of a single le.An exampleis -follow, which instructs find to follow symbolic links instead of just stating the inode.Theyalways return true.tests are real tests for example, -empty checks whether the le is empty , and can return true orfalse.actions have also a side e ect the name of the considered le.They can return true or false too.operators do not really return a value they can conventionally be considered as true , and areused to build compress expression.An example is -or, which takes the logical OR of the twosubexpressions on its side.Notice that when juxtaposing expression, a -and is implied.Note that find relies upon the shell to have the command line parsed; it means that all keywordmust be embedded in white space and especially that a lot of nice characters have to be escaped,otherwise they would be mangled by the shell itself.Each escaping way backslash, single and doublequotes is OK; in the examples the single character keywords will be usually quoted with backslash,because it is the simplest way at least in my opinion.But it's me who is writing these notes!11.1.3 OptionsHere there is the list of all options known by GNU version of find.Remember that they alwaysreturn true. 11.1.FIND, THE FILE SEARCHER 117-daystart measures elapsed time not from 24 hours ago but from last midnight.A true hackerprobably won't understand the utility of such an option, but a worker who programs fromeight to ve does appreciate it.-depth processes each directory's contents before the directory itself.To say the truth, I don'tknow many uses of this, apart for an emulation of rm -F command of course you cannot deletea directory before all les in it are deleted too.-follow deferences that is, follows symbolic links.It implies option -noleaf; see below.-noleaf turns o an optimization which says A directory contains two fewer subdirectoriesthan their hard link count".If the world were perfect, all directories would be referenced byeach of their subdirectories because of the.option , as.inside itself, and by it's real"name from its parent directory.That means that every directory must be referenced at least twice once by itself, once byits parent and any additional references are by subdirectories.In practice however, symboliclinks and distributed lesystems1 can disrupt this.This option makes find run slightly slower,but may give expected results.-maxdepth levels , -mindepth levels , where levels is a non-negative integer, respectively saythat at most or at least levels levels of directories should be searched.A couple of exam-ples is mandatory: -maxdepth 0 indicates that it the command should be performed just onthe arguments in the command line, i.e., without recursively going down the directory tree;-mindepth 1 inhibits the processing of the command for the arguments in the command line,while all other les down are considered.-version just prints the current version of the program.-xdev, which is a misleading name, instructs find not to cross device, i.e.changing lesystem.It is very useful when you have to search for something in the root lesystem; in many machinesit is a rather small partition, but a find would otherwise search the whole structure!11.1.4 TestsThe rst two tests are very simple to understand: -false always return false, while -true alwaysreturn true [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • funlifepok.htw.pl
  •  

    Drogi użytkowniku!

    W trosce o komfort korzystania z naszego serwisu chcemy dostarczać Ci coraz lepsze usługi. By móc to robić prosimy, abyś wyraził zgodę na dopasowanie treści marketingowych do Twoich zachowań w serwisie. Zgoda ta pozwoli nam częściowo finansować rozwój świadczonych usług.

    Pamiętaj, że dbamy o Twoją prywatność. Nie zwiększamy zakresu naszych uprawnień bez Twojej zgody. Zadbamy również o bezpieczeństwo Twoich danych. Wyrażoną zgodę możesz cofnąć w każdej chwili.

     Tak, zgadzam się na nadanie mi "cookie" i korzystanie z danych przez Administratora Serwisu i jego partnerów w celu dopasowania treści do moich potrzeb. Przeczytałem(am) Politykę prywatności. Rozumiem ją i akceptuję.

     Tak, zgadzam się na przetwarzanie moich danych osobowych przez Administratora Serwisu i jego partnerów w celu personalizowania wyświetlanych mi reklam i dostosowania do mnie prezentowanych treści marketingowych. Przeczytałem(am) Politykę prywatności. Rozumiem ją i akceptuję.

    Wyrażenie powyższych zgód jest dobrowolne i możesz je w dowolnym momencie wycofać poprzez opcję: "Twoje zgody", dostępnej w prawym, dolnym rogu strony lub poprzez usunięcie "cookies" w swojej przeglądarce dla powyżej strony, z tym, że wycofanie zgody nie będzie miało wpływu na zgodność z prawem przetwarzania na podstawie zgody, przed jej wycofaniem.