Create a document with four lines, each containing the word “today.” What command would you use to save the file, and exit vi?

Display the complete command that will accomplish the following actions. (ie. If you were asked which command would allow you to navigate to the /var directory you would display the following:  cd /var (NOT just the command cd))

 Vi Editor

  1. Using the vi editor:

Create a document with four lines, each containing the word “today.” What command would you use to save the file, and exit vi?

 

 

  1. Using the vi editor:

Create a document called first.file, and enter a few lines of text in it. Save it. Create a second document called second.file, and enter a few lines of text in it. Save it.

 

What commands would you use to create a third document called third.file by merging the text from the first two files? (3 pts)

 

 

  1. Using the vi editor, delete all the text from file.

 

What command would you use to restore the data you just deleted?

 

 

  1. Using the vi text editor create a file with 12 lines of text and on the fifth line insert your first and last name.

 

What command would you use to go to the first line of the file?

 

 

What command would you use to search the file for your last name?

 

 

What command would you use to save the file, but not exit vi?

 

Without exiting vi, temporarily execute the ls command to confirm that the file is saved.

 

What command did you use temporarily leave vi (without exiting it) so you could execute the “ls” command?

 

 

 

What command can you use that will cause line numbers to appear?

 

 

 

 

Scripting

  1. Next, use the command to add your current working directory to the PATH

 

 

  1. What command will create a variable called iam and assign the results of the whoami

command to it?

 

 

 

 

  1. Assign the variable T the value of Next, assign the variable S the value of T+30. Finally, display the contents of T and S to verify you have correctly defined these variables.

 

  1. Create a script with a for loop that uses the variable sandwiches and then displays a line at a time the following sandwiches: chicken, ham, hummus, tomato. (4 points)

 

9.Someone wrote the following script but it doesn’t work and you’ve been asked to troubleshoot What is wrong with the following lines of code? (4 points)

 

While [ “$value” = “100” ; do

 

ECHO “That’s a large number.” read value