Chapter02-Accessing The Command Line
Chapter02-Accessing The Command Line
On workstation, run the lab cli-review start script to set up a clean lab
environment. The script also copies the zcat file to student's home directory.
1. Use the date command to display the current time and date.
2. Display the current time in 12-hour clock time (for example, 11:42:11 AM). Hint: The format
string that displays that output is %r.
Use the +%r argument with the date command to display the current time in 12-hour clock
time.
4. Use the wc command and Bash shortcuts to display the size of zcat.
The wc command can be used to display the number of lines, words, and bytes in the zcat
script. Instead of retyping the file name, use the Bash history shortcut Esc+. (the keys Esc
and . pressed at the same time) to reuse the argument from the previous command.
42 RH124-RHEL8.0-en-1-20190531
CHAPTER 2 | Accessing the Command Line
case $1 in
--help) printf '%s\n' "$usage" || exit 1;;
--version) printf '%s\n' "$version" || exit 1;;
esac
[student@workstation]$ !!
tail zcat
With no FILE, or when FILE is -, read standard input.
case $1 in
--help) printf '%s\n' "$usage" || exit 1;;
RH124-RHEL8.0-en-1-20190531 43
CHAPTER 2 | Accessing the Command Line
8. Repeat the previous command, but use the -n 20 option to display the last 20 lines in the
file. Use command-line editing to accomplish this with a minimal number of keystrokes.
UpArrow displays the previous command. Ctrl+A makes the cursor jump to the beginning
of the line. Ctrl+RightArrow jumps to the next word, then add the -n 20 option and hit
Enter to execute the command.
case $1 in
--help) printf '%s\n' "$usage" || exit 1; exit;;
--version) printf '%s\n' "$version" || exit 1; exit;;
esac
9. Use the shell history to run the date +%r command again.
Use the history command to display the list of previous commands and to identify the
specific date command to be executed. Use !number to run the command, where number is
the command number to use from the output of the history command.
Note that your shell history may be different from the following example. Determine the
command number to use based on the output of your own history command.
44 RH124-RHEL8.0-en-1-20190531
CHAPTER 2 | Accessing the Command Line
Evaluation
On workstation, run the lab cli-review grade script to confirm success on this exercise.
Finish
On workstation, run the lab cli-review finish script to complete the lab.
RH124-RHEL8.0-en-1-20190531 45