grep command do in a script?grep searches for lines in a file or input that match a given pattern. It helps find specific text quickly.
grep to search for the word "apple" in a file named fruits.txt?Use the command: grep 'apple' fruits.txt. It will show all lines containing "apple".
-i option do in grep?The -i option makes the search case-insensitive. It finds matches regardless of uppercase or lowercase letters.
grep be used in a script to check if a pattern exists and then run a command?You can use grep with an if statement. For example:<br>if grep -q 'pattern' file.txt; then echo 'Found'; fi<br>This runs the echo only if the pattern is found.
-q option do in grep?The -q option makes grep run quietly. It does not print output but sets the exit status to indicate if a match was found.
grep 'dog' pets.txt do?grep searches and shows lines matching the pattern. It does not delete or replace text.
grep option makes the search ignore case?The -i option makes grep ignore case differences.
-q option do in grep?-q makes grep silent and only sets the exit status.
grep in a script to run a command only if a pattern is found?The if statement with grep -q checks for the pattern quietly and runs commands conditionally.
grep -v 'cat' animals.txt do?The -v option inverts the match, showing lines that do NOT contain the pattern.
grep in a bash script to check if a file contains a specific word and then print a message.grep with and without the -i option.