Sed MCQ : 1


Q. How to print contents of a file?





Contributed by: admin

Input fileName:

Line No: 1: awk is a versatile text-processing tool that works by scanning files or input line by line and performing specified actions.
Line No: 2: It was developed in the 1970s and named after its creators—Alfred Aho, Peter Weinberger, and Brian Kernighan.
Line No: 3: awk is particularly useful for pattern scanning and processing, making it a go-to tool for extracting and transforming text in Unix-like environments.
Line No: 4: With its syntax resembling a simple programming language, awk provides features like variables, loops, and conditionals.
Line No: 5: Why should you learn awk?
Line No: 6: Because it allows you to quickly process structured text like logs, CSV files, or any text organized into rows and columns.
Line No: 7: For example, you can print the second column of a file with a single command: awk '{print $2}' file.txt.
Line No: 8: You can also filter lines based on patterns, like finding all lines containing "error" using: awk '/error/' file.txt.
Line No: 9: Advanced awk scripts can perform arithmetic, transform text, and even generate reports—all with concise and readable code.