DispersedNet
SiteMap
Unix Concepts
Shell Programming
Shell Scripting
Unix Questions
Unix Commands
«Prev
Next»
Shell Programming
Shell Processes
login Shell
Define Unix Process
Starting Other Shells
Parent Child Processes
3 Ways Shell Script
Specify Shell Script
Unix Path Variable
Shell Script Conclusion
Embedded Commands
Defining embedded Execution
Embedded Command Syntax
Application Embedded Execution
Date Command Options
forLoop Embedded Execution
insert Carriage Return
embedded Command Conclusion
Unix Commands
Find Command
wc Command
sort Command
read in Variables
Sleep Clear Commands
Grep Command
coption to grep
tee Command
Shell Script
Debugging Shell Scripts
Tracing Shell Scripts
Handling Errors
Printing Progress
Writing Shell Functions
–c option grep - Exercise
The –c option to grep
Objective:
Practice writing regular expressions and grep commands
Exercise scoring
This exercise is worth 5 points and is auto-scored.
Instructions
1. Access the clothes file located in your home directory.
2. Write a
grep
command to list lines containing Black in the clothes file.
3. Write a command to count the number of lines containing the string “pair of shoes” in the clothes file.
4. Write an assignment statement to save the output of the previous command in a variable called count. Use embedded command execution.
First, run the command below to create a variable called item.
$ item=”pair of shoes”
5. Then, write an assignment statement to create a variable called itemcount. This variable will store the number of lines matching “pair of shoes” in the clothes file. Use embedded command execution.