Introduction
Scripts often work with text because text files are simple and easy to read or change. Many system tasks, like logs or settings, use text, so scripts handle text to automate these tasks.
command [options] [arguments]
grep 'error' logfile.txtsed 's/old/new/g' file.txtawk '{print $1}' data.txt#!/bin/bash # This script finds lines with 'fail' in a log and counts them fail_count=$(grep -i 'fail' system.log | wc -l) echo "Number of failures found: $fail_count"
error in a file named log.txt using grep?grep [pattern] [file].error is the pattern and log.txt is the file to search.echo "apple banana cherry" | awk '{print $2}'pets.txt. What is wrong?sed 's/cat/dog/g pets.txt'
error from multiple log files and save them into a single file errors.txt. Which script snippet correctly does this?grep error *.log searches for 'error' in all files ending with .log.Pass the test and this pattern moves unknown