Cat, watch the lottery.
Function: View file contents
Example 1: Check the test.txt file and check the line number of the file.
cat -n text.txt
Example 2: Check the test.txt file and check the line number of the file except the blank line.
cat -d text.txt
Command: More-[Options] [File Name]
Function: View file contents
Note: cat looks at all the contents, and more only displays one page. Click the spacebar to see what follows.
Command: grep -[ options] [search term] [file name]
Function: Find the specified text contained in the file and highlight grep to allow pattern search (regular expression) on the text file.
Example 1: find the cat character in the test.txt file.
grep cat test.txt
Example 2: Find the cat character in the test.txt file and display the line number.
grep -n cat test.txt
Example 3: Find cat character lines that are not included in the test.txt file.
grep -v cat test.txt
Example 4: find the cat character in the test.txt file, ignoring the case.
grep -i cat test.txt
Example 5: Search by.
Grep ^a test. txt
Example 6: Search to
grep a$ test.txt