Lab#3

Lab 3 Description

In this lab we will test the following commands: >, <, |, grep, head, tail, and echo.

> command

The following command allows for the user to redirect their output from stdout to another location. In the following case the list of folders stored in the keven directory are outputted to a text file name ls-output.txt.

output command redirect

< command

The following command is used to redirect input to another location. In which case the cat > command is used to read input and copies it onto the input_file.txt. Following this to view what was typed as input the cat < command is used with input_file.txt.

input command redirect

| command

The following command is allows pipelines to be created in which case the user can have a output be redirect as a input into another command. In the following case we have the ls command be output redirected with sorting into the less command to display the folder in the directory.

vertical line command

grep command

The following command looks for text patterns of files in which case when it finds it will list out the ones containing it. It functions as a search option. In the following case grep is used to look in the specified directory for text files. After finding them it lists all the files containing txt out.

grep command

head command

The following command prints out the first 10 lines of the specified file. When used with -n 5 it only prints out the first 5 lines of the file. In the following case what is printed out is the first 10 lines of the input_file.txt and then the first 5 lines following after.

head command

tail command

The following command prints out the last 10 lines of the specified file. When used with -n 5 it only prints out the last 5 lines of the file. In the following case what is printed out is the last 10 lines of the input_file.txt and then the last 5 lines following after.

tail command

echo command

The following command is used to display text. In the following case echo is used to online a line of text. Following this it is used to with wildcards D* and k* where it looks for files beginning with those letters case specified. In addition, echo command allows for arithmetic to done as well through the use of the $((expression)). As can be seen 5*5=25 is done and so is a longer math expression where ((((5*5)-7)+18))%11)=3.

echo command

Leave a Reply

Your email address will not be published. Required fields are marked *