Grep, pipes, filters, top, redirection and append
Learning outcomes:
- Demonstrate the use of grep to filter a text file
- Use redirection (or append) in a command and explain what is happening
- Show the use of head, tail and diff
Would you like to download my PowerPoint to follow along?
- Grep
- grep is a command to filter lines that contain specific text
- Examples
- cat /etc/passwd
- cat /etc/passwd | grep Jane
- cat /etc/passwd | grep Jane |wc -l
- cat /etc/passwd | grep -v Jane
- Redirect and append
- Redirect >
- Append >>
- What's the difference? Redirect erases the file contents, append puts the results at the end of the file
- Display file options
- cat Used to display a file
- Alternatives head, tail and od
- head displays top (default 10) lines
- tail displays end (defaults to 10) lines
- od displays any file by showing hex code
- File comparison
- Tar
Suggested Activities and Discussion Topics:
- Follow along with me on This video on how to use tar
Would you like to see some more classes?
Click here