Chapter 14, Working with Apache and Other Log Files

  1. Runtime exceptions occur during execution of the program and they exit abruptly in between. Compile time exceptions are those that are found before program executions start.
  2. A regular expression, regex, or regexp is a sequence of characters that define a search pattern. Usually this pattern is used by string searching algorithms for find or find and replace operations on strings, or for input validation.
  3. Here's a description of the Linux commands:
    • head: used to see the first N number of lines of plain files.
    • tail: used to see the last N number of lines of plain files.
    • cat: used to see the content of plain files.
    • awk: AWK is a programming language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems.
  4. Following is the answer:
def append(source, destination):
with open(source, "a") as fw, open(destination,"r") as fr:
fw.writelines(fr)
append(source_file_name1, file_name2)
  1. Following is the answer:
filename=input("Enter file name: ")
for line in reversed(list(open(filename))):
print(line.rstrip())
  1. The output for the expressions are as follows:
    1. C@ke
    2. Cooookie
    3. <h1>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset