1. Trang chủ
  2. » Công Nghệ Thông Tin

Secure PHP Development- P171 ppt

5 97 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 85,21 KB

Nội dung

option, a long listing containing file/directory permission information, size, modi- fication date, and so on, are displayed. The -a option allows you to view all files and directories (including the ones that have a leading period in their names) within the current directory. The -R option allows the command to recursively dis- play contents of the subdirectories (if any). mkdir Syntax: mkdir directory . . . To make a directory, use the mkdir command. You have only two restrictions when choosing a directory name: (1) File names can be up to 255 characters long, and (2) directory names can contain any character except the slash (/). For example, mkdir dir1 dir2 dir3 The preceding example creates three subdirectories in the current directory. mv Syntax: mv [-if] sourcefile targetfile Use the mv command to move or rename directories and files. The command per- forms a move or rename depending on whether the targetfile is an existing directory. To illustrate, suppose you would like to give a directory called foo the new name of foobar: mv foo foobar Because foobar does not already exist as a directory, foo becomes foobar. If you issue the following command: mv doc.txt foobar and foobar is an existing directory, you perform a move. The file doc.txt now resides in the directory foobar. The -f option removes existing destination files and never prompts the user. The -i option prompts the user whether to overwrite each destination file that exists. If the response does not begin with y or Y, the file is skipped. 826 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 826 pwd Syntax: pwd This command prints the current working directory. The directories displayed are the absolute path. None of the directories displayed are hard or soft symbolic links. pwd /home/usr/charmaine rm Syntax: rm [-rif] directory/file To remove a file or directory, use the rm command, as shown in the following examples: rm doc.txt rm ~/doc.txt rm /tmp/foobar.txt To remove multiple files with rm, you can use wildcards or type each file indi- vidually. For example, rm doc1.txt doc2.txt doc3.txt is equivalent to rm doc[1-3].txt rm is a powerful command that can cause chaos if you use it incorrectly. For instance, suppose that you have been working on your thesis for the last six months. You decide to rm all of your docs, thinking you are in another directory. After finding out that a backup file does not exist (and you are no longer in denial), you wonder whether there was any way you could have prevented this. The rm command has the -i option, which allows rm to be interactive. This tells rm to ask your permission before removing each file: rm -i *.doc rm: remove thesis.doc (yes/no)? n Appendix D: Linux Primer 827 34 549669 AppD.qxd 4/4/03 9:28 AM Page 827 The -i option gives you a parachute. It’s up to you to either pull the cord (answer no) or suffer the consequences (answer yes). The -f option is completely the opposite. The -f (force) option tells rm to remove all the files you specify, regardless of the file permissions. Use the -f option only when you are 100 percent sure that you are removing the correct file(s). To remove a directory and all files and subdirectories within it, use the -r option. rm -r will remove an entire subtree, as shown here: rm -r documents If you are not sure what you are doing, combine the -r option with the -i option: rm -ri documents The preceding example asks for your permission before it removes every file and directory. sort Syntax: sort [-rndu] [-o outfile] [infile/sortedfile] The obvious task this command performs is to sort. However, sort also merges files. The sort command reads files that contain previously sorted data and merges them into one large, sorted file. The simplest way to use sort is to sort a single file and display the results on your screen. As an example, suppose that a.txt contains the following: b c a d To sort a.txt and display the results to the screen, use the following: sort a.txt a b c d 828 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 828 To save the sorted results, use the -o option: sort -o sorted.txt a.txt saves the sorted a.txt file in sorted.txt. To use sort to merge existing sorted files and to save the output in sorted.txt, use sort -o sorted.txt a.txt b.txt c.txt The -r option for this command reverses the sort order. Therefore, a file that contains the letters of the alphabet on a line is sorted from z to a if you use the -r option. The -d option sorts files based on dictionary order. The sort command consid- ers only letters, numerals, and spaces, ignoring other characters. The -u option looks for identical lines and suppresses all but one. Therefore, sort produces only unique lines. stat Syntax: stat file This program displays various statistics on a file or directory, as shown in the following example: stat foo.txt This command displays the following output: File: ‘foo.txt’ Size: 4447232 Filetype: Regular File Mode: (0644/-rw-r r ) Uid: ( 0/root) Gid: (0/root) Device: 3,0 Inode: 16332 Links: 1 Access: Fri Aug 2 21:39:43 2002(00000.02:32:30) Modify: Fri Aug 2 22:14:26 2002(00000.01:57:47) Change: Fri Aug 2 22:14:26 2002(00000.01:57:47 You can see the following displayed: file access; modification; change date; size; owner and group information; permission mode; and so on. strings Syntax: strings filename The strings command prints character sequences at least four characters long. You use this utility mainly to describe the contents of nontext files. Appendix D: Linux Primer 829 34 549669 AppD.qxd 4/4/03 9:28 AM Page 829 tail Syntax: tail [-count | -fr] filename The tail command displays the end of a file. By default, tail displays the last 10 lines of a file. To display the last 50 lines of the file doc.txt, you issue the following command: tail -50 doc.txt The -r option displays the output in reverse order. By default, -r displays all lines in the file, not just 10 lines. For instance, use the following to display the entire contents of the file doc.txt in reverse order: tail -r doc.txt To display the last 10 lines of the file doc.txt in reverse order, use this: tail -10 -r doc.txt Finally, the -f option is useful when you are monitoring a file. With this option, tail waits for new data to be written to the file by some other program. As new data is added to the file by some other program, tail displays the data on the screen. To stop tail from monitoring a file, press Ctrl+C (the intr key) because the tail command does not stop on its own. touch Syntax: touch file or directory This command updates the timestamp of a file or directory. If the named file does not exist, this command creates it as an empty file. uniq Syntax: uniq [-c] filename The uniq command compares adjacent lines and displays only one unique line. When used with the -c option, uniq counts the number of occurrences. For exam- ple, a file with the following contents: 830 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 830

Ngày đăng: 07/07/2014, 07:20

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN