1 / 18

Workbook 8

Workbook 8. Chapters 5-9. Introduction. In Linux (like Unix before it), nearly all configuration information is stored in text files. Contrast this with Windows, which stores configuration information in a huge, monolithic database called The Registry.

simone
Télécharger la présentation

Workbook 8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Workbook 8 Chapters 5-9

  2. Introduction • In Linux (like Unix before it), nearly all configuration information is stored in text files. • Contrast this with Windows, which stores configuration information in a huge, monolithic database called The Registry. • Text files are generally easier to set up and work with. • Linux includes a rich set of tools for viewing and editing text files. The following chapters describe some of these.

  3. Chapter 5: cut and paste commands • cut: selects columns of text in a text file. • Commands like head, tail, and grep can be considered to make “horizontal” cuts in a file. • cut can be considered to make “vertical” cuts in a file.

  4. Switches for the cut command • Select character columns with the –c switch. • Select fields with the –f switch. • Select bytes with the –b switch (essentially the same as –c in most circumstances). • Specify the field delimiter character with the –d switch (tab is default).

  5. Example 1 List files with a .txt “extension” with inodes: Show only inodes, owner, and file name:

  6. Example 2 Look at the last 5 lines of /etc/passwd: Pick out user ID number, user ID, and name: Note the fields are in the original order, in spite of the order we requested them!

  7. The paste command • Appends files horizontally, line by line • Example: put user ID number, user ID, and user name in the order we want them:

  8. Chapter 6: the diff command • Compares two files, and reports the differences between them. • Example: modifying user data.

  9. Some diff command line switches

  10. More switches • diff can be quite picky, and report all sorts of changes which are trivial and ultimately meaningless. Here are some switches to ease the pain:

  11. Chapter 7: the tr command • Performs character translations (substitutions, deletions, squeezing) on the input stream and passes the modified string to the output stream. • Example 1: substituting characters

  12. Example: deleting characters All spaces have been deleted.

  13. Example: squeezing characters Fields are now separated by a single space.

  14. Chapter 8: the aspell command • aspell is used for spell-checking text files. • Example:

  15. Using aspell • aspell can be used on the stdin and stdout streams as illustrated in the previous example. • It can also be used to start an interactive spell check session: aspell –c filename • This will highlight any word it can’t find in the dictionary in turn, and offer you a range of alternatives for correction. • As usual, if there are no misspelled words, it says nothing at all.

  16. aspell dictionaries • Two dictionaries are used by default: • The system-wide master dictionary in /usr/share/dict • A user-specific dictionary stored in.aspell.en.pws • A list of corrections made is kept in .aspell.en.prepl. • Note: the .en. refers to English; other languages can be used as well.

  17. Chapter 9: fmt and split commands • The fmt command is generally used to break long lines up into shorter ones by inserting newline characters. • The split command is used to split large files into a set of smaller files with a common prefix.

  18. Conclusion • Linux includes many commands for viewing, formatting, and manipulating text files. • This is useful, because nearly all configuration information is stored in text files. • This rich set of text editing tools helps system administrators maintain their Linux system.

More Related