Objective:
- Create a new page in your portfolio and name it âLab 3â with âEMT 2390Lâ as its parent.
- For each of the following commands write a description of what it does and provide a screenshot with an example of its usage:
- >
- <
- |
- grep
- head
- tail
- echo
Command: >
Description: Redirect output from stdout
Entering the command cat>test.txt created a text file name test. After entering the command what I write after is placed into that file. It allows the user to input text and using control c to paste it.
Command: <
Description: Redirect input
Allows the user to see the content inside a file. In the picture below you can see when the command cat<test.txt is entered it will then display the content of the file.
Note: The content of the file is different from the content originally placed in the file. This was because I open the test.txt file and alter the contents and saved it to become more familiar with the command and how it works.
Command: |
Description: | allows you to redirect the output of one command and pipe it as input to another
It reads the input that is given and and copy ls|less
Command: grep
Description: Search file for lines that match a given pattern
The grep command is used to search text or searches the given file for lines containing a match to the given strings or words. By default, grep displays the matching lines. You can use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. grep is considered as one of the most useful commands on Unix and other Linux operating systems.
Command: head
Description: Output the first 10 lines of a file
The head command display the first 10 lines by default of any text given to it as an input and writes them to standard output which, by default, is the display screen.
head [options] [file(s)] <– You can select an option and the file name you want to view.
If you wish to obtain some number of lines other than the default ten, the -n option can be used followed by an integer indicating the number of lines desired. For example head -n15 test.txt.
Command: tail
Description: Output the last 10 lines of a file
The tail command display the last 10 lines by default of any text given to it as an input and writes them to standard output which, by default, is the display screen.
tail [options] [file(s)] <– You can select an option and the file name you want to view.
If you wish to obtain some number of lines other than the default ten, the -n option can be used followed by an integer indicating the number of lines desired. For example tail -n15 test.txt.
Command: echo
Description: Display message on screen, writes each given STRING to standard output, with a space between each and a newline after the last one
echo is one of the most commonly and widely used built-in command for Linux bash and C shells, that typically used in scripting language and batch files to display a line of text/string on standard output or a file.
As you can see I used the echo command to write a simple mathematical equation and after entering the command it displayed the output / answer of that mathematical equation.