In this lab you edit a text file with the vim editor.
Outcomes
Use Vim to edit files.
Use Vim visual mode to simplify editing large files.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start edit-review
Instructions
On workstation, create the lab_file shell variable and assign editing_final_lab.txt as the value.
List the student home directory, including hidden directories and files, and redirect the output to the editing_final_lab.txt file by using the shell variable.
On the workstation machine, create the lab_file shell variable and assign a value of editing_final_lab.txt.
Use the ls -al command in the student home directory and redirect the output to the editing_final_lab.txt file.
[student@workstation ~]$lab_file=editing_final_lab.txt[student@workstation ~]$ls -al > $lab_file
Use Vim to edit the editing_final_lab.txt file.
Use the lab_file shell variable.
Enter the line-based visual mode of Vim.
Your screen output might differ from these examples.
Remove the first three lines of the editing_final_lab.txt file.
Enter the visual mode of Vim. Remove the last seven characters from the first column on the first line. Preserve only the first four characters of the first column.
Use the arrow keys to position the cursor at the last character of the first column on the first line. Delete the selection by typing x.
Enter the visual block mode of Vim. Repeat the operation of the previous step, but this time select from the second to the last line. Preserve only the first four characters of the first column.
Enter the visual block mode of Vim and remove the fourth column of the file.
Enter the visual block mode of Vim to remove the time column, to leave the month and day columns on all lines.
Enter the visual line mode of Vim and remove the rows that contain the Desktop and Public strings.
Save your changes and exit the file.
Back up the editing_final_lab.txt file and append the date (in seconds) at the end of the file name preceded with an underscore (_) character.
Use the lab_file shell variable.
Append a dashed line to the editing_final_lab.txt file.
The dashed line should contain 12 dash (-) characters for this lab to be graded correctly.
Use the lab_file shell variable.
List the content of the Documents directory, and append the output to the editing_final_lab.txt file, and display the output in the terminal.
Use the tee command and the lab_file shell variable.
Confirm that the directory listing is at the bottom of the lab file.
Use the lab_file shell variable.
[student@workstation ~]$ cat $lab_file
drwx 3 student 17 Mar 4 .ansible
-rw- 1 student 18 Nov 5 .bash_logout
-rw- 1 student 141 Nov 5 .bash_profile
-rw- 1 student 492 Nov 5 .bashrc
drwx 9 student 4096 Mar 8 .cache
drwx 8 student 4096 Mar 8 .config
drwx 2 student 6 Mar 8 Documents
drwx 2 student 6 Mar 8 Downloads
-rw- 1 student 0 Mar 8 editing_final_lab.txt
drwx 2 student 25 Mar 4 .grading
drwx 4 student 32 Mar 8 .local
drwx 2 student 6 Mar 8 Music
drwx 2 student 6 Mar 8 Pictures
drwx 2 student 77 Mar 4 .ssh
drwx 2 student 6 Mar 8 Templates
drwx 3 student 18 Mar 4 .venv
drwx 2 student 6 Mar 8 Videos
------------
lab_review.txtThis concludes the section.