Skip to content

Commit 5d50f7d

Browse files
authored
Solved the ids for the symbols $ to ? for basic shell commands fixes issue #358 (#361)
Shortens the description from $ - ? in the symbols index page in Runestone. Fixes issue#358
2 parents 756fb9c + 831f16c commit 5d50f7d

File tree

1 file changed

+81
-120
lines changed

1 file changed

+81
-120
lines changed

source/sec_dev_basic_shell_commands.ptx

Lines changed: 81 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@
1111
</p>
1212
</introduction>
1313

14-
<subsection xml:id="subsec-files_directories_privileges">
15-
<title>Files, Directories, and Privileges</title>
16-
<p>
17-
This and subsequent subsections are written to be followed as an extended exercise with explanations given as we go.
18-
</p>
19-
<exercise xml:id="exercise-try-cli">
14+
<subsection xml:id="subsec-intro_shell_commands">
15+
<title>Introduction to Shell Commands</title>
16+
<exercise xml:id="exercise-try-cli">
2017
<title>Exercise: Try shell commands for navigation</title>
18+
2119
<p>Try each of the following commands on your own machine.</p>
2220
</exercise>
23-
<p>
24-
First, follow the directions given in <xref ref="subsec-getting_terminal"/> to open a terminal window so you can use your shell. All of the shell commands will be typed in this terminal window.
25-
</p>
26-
<paragraphs>
27-
<title>Introduction to Shell Commands</title>
21+
<p>
22+
This and subsequent subsections are written to be followed as an extended exercise with explanations given as we go.
23+
</p>
24+
<p>
25+
This section is written to be followed as an extended exercise with explanations given as we go.
26+
</p>
2827
<p>
2928
</p>
3029
<p>
@@ -94,9 +93,9 @@
9493
<p>
9594
The reason you see something like this is because the SHELL environment variable stores the location of the shell program. This location, called the <term>file path</term>, is given in the form of the path needed to find the location. We explore how this path is described in the next section.
9695
</p>
96+
</subsection>
9797

98-
</paragraphs>
99-
<paragraphs>
98+
<subsection xml:id="subsec-files_and_file_systems">
10099
<title>Files and File Systems</title>
101100
<p>
102101
</p>
@@ -156,9 +155,9 @@
156155
<p>
157156
You should see a listing of files and directories.
158157
</p>
158+
</subsection>
159159

160-
</paragraphs>
161-
<paragraphs>
160+
<subsection xml:id="subsec-shell_command_options">
162161
<title>Shell Command Options</title>
163162
<p>
164163
</p>
@@ -187,10 +186,10 @@ lrwxrwxrwx 1 root root 7 Mar 24 2022 bin -> usr/bin
187186

188187
<p>
189188
Thus, the <c>-l</c> flag changed how the listing is displayed.
190-
</p>
191-
192-
</paragraphs>
193-
<paragraphs>
189+
</p>
190+
</subsection>
191+
192+
<subsection xml:id="subsec-file_permissions">
194193
<title>File Permissions</title>
195194
<p>
196195

@@ -219,9 +218,9 @@ lrwxrwxrwx 1 root pearcej 7 Mar 24 2022 bin -> usr/bin
219218
<p>
220219
Occasionally, you need to change permissions of a file. For example, you might need to change permissions to make a file executable. Changing file permissions is done with the <c>chmod</c> command. We will explore this in a bit.
221220
</p>
222-
</paragraphs>
221+
</subsection>
223222

224-
<paragraphs>
223+
<subsection xml:id="subsec-command_options">
225224
<title>Learning More About Command Options</title>
226225
<p>
227226
</p>
@@ -242,8 +241,8 @@ lrwxrwxrwx 1 root pearcej 7 Mar 24 2022 bin -> usr/bin
242241
<pre>
243242
ls -lra
244243
</pre>
245-
</paragraphs>
246-
<paragraphs>
244+
</subsection>
245+
<subsection xml:id="subsec-creating_removing_directories">
247246
<title>Creating and Removing Directories</title>
248247
<p>
249248
</p>
@@ -333,8 +332,8 @@ lrwxrwxrwx 1 root pearcej 7 Mar 24 2022 bin -> usr/bin
333332
pwd
334333
</pre>
335334

336-
</paragraphs>
337-
<paragraphs>
335+
</subsection>
336+
<subsection xml:id="subsec-input_output_redirection">
338337
<title>Input and Output Redirection</title>
339338
<p>
340339
</p>
@@ -484,9 +483,9 @@ wc -w &lt; temp.txt
484483
Try it! This is an improvement because it is faster and avoids the use of a temporary file.
485484
</p>
486485

487-
</paragraphs>
486+
</subsection>
488487

489-
<paragraphs>
488+
<subsection xml:id="subsec-scripts">
490489
<title>Scripts</title>
491490
<p>
492491

@@ -546,9 +545,9 @@ wc -w &lt; temp.txt
546545
chmod +x hellouser.sh
547546
./hellouser.sh
548547
</pre>
549-
</paragraphs>
548+
</subsection>
550549

551-
<paragraphs>
550+
<subsection xml:id="subsec-file_management">
552551
<title>File Management</title>
553552
<p>
554553
</p>
@@ -614,21 +613,19 @@ rm -i newfile4.txt
614613
<p>
615614
And, if you respond with "n", then the removal will not happen.
616615
</p>
617-
</paragraphs>
618-
<paragraphs>
616+
</subsection>
617+
<subsection xml:id="subsec-shell_commands">
619618
<title>A few time-saving shell commands</title>
620619
<p>
621-
622-
</p>
623-
<p>
624-
The <em>up arrow</em> key retrieves the previous shell command. If you press it multiple times, it will take you back through multiple commands in your shell history. This is a useful way to repeat a command. For example, if you had a typo, you can use the up arrow, edit the command, and push enter to fix the command. Analogously, the <em>down arrow</em> will move you in the reverse direction through the shell command history. For more useful shell commands, type <c>man bash</c> for hints on how to search your shell history, re-execute commands, and much more.
625620
</p>
626621
<p>
622+
The <em>up arrow</em> key retrieves the previous shell command. If you press it multiple times, it will take you back through multiple commands in your shell history. This is a useful way to repeat a command. For example, if you had a typo, you can use the up arrow, edit the command, and push enter to fix the command. Analogously, the <em>down arrow</em> will move you in the reverse direction through the shell command history. For more useful shell commands, type <c>man bash</c> for hints on how to search your shell history, re-execute commands, and much more.
623+
</p>
627624
<p>
628-
An additional efficiency-enhancing feature is the <term>history</term> command. This command conveniently presents a record of previously executed shell commands, enabling users to effortlessly revisit their command history.
625+
An additional efficiency-enhancing feature is the <term>history</term> command. This command conveniently presents a record of previously executed shell commands, enabling users to effortlessly revisit their command history.
629626
</p>
630627
<p>
631-
Here's an example of what might be displayed when the <c>history</c> command is executed:
628+
Here's an example of what might be displayed when the <c>history</c> command is executed:
632629
</p>
633630
<pre>
634631
1 git init
@@ -639,9 +636,8 @@ And, if you respond with "n", then the removal will not happen.
639636
6 history
640637
</pre>
641638

642-
<p>
639+
<p>
643640
This paragraph is intended to alert you to some useful search features. A couple examples of very common search patterns are using wildcards for zero or more characters or for a single character. The asterisk (*) specifies zero or more characters to match. In bash the question mark (?) is used for matching exactly one single character.
644-
</p>
645641
<notation>
646642
<usage><m>*</m></usage>
647643
<description>asterisk - wildcard for zero or more characters</description>
@@ -650,116 +646,81 @@ And, if you respond with "n", then the removal will not happen.
650646
<usage><m>?</m></usage>
651647
<description>question mark - wildcard for single character</description>
652648
</notation>
653-
</p>
654-
<p>
655-
For example, if we type the following:
656-
</p>
657-
<pre>
649+
</p> <p>
650+
For example, if we type the following:
651+
</p>
652+
<pre>
658653
rm -i newfile?.txt
659654
</pre>
660-
<p>
655+
<p>
661656
Then the question mark will match with any single character, and we will see the following prompts:
662657
</p>
663-
<pre>
658+
<pre>
664659
rm: remove regular file 'newfile2.txt'?
665660
rm: remove regular file 'newfile4.txt'?
666661
</pre>
667-
<p>
662+
<p>
668663
If we instead type:
669664
</p>
670-
<pre>
665+
<pre>
671666
rm -i newfile*.txt
672-
</pre>
673-
<p>
667+
</pre>
668+
<p>
674669
Then the asterisk will match with any number of characters (including zero), and we will see the following prompts:
675670
</p>
676-
<pre>
671+
<pre>
677672
rm: remove regular file 'newfile2.txt'?
678673
rm: remove regular file 'newfile4.txt'?
679674
rm: remove regular file 'newfile2_cp.txt'?
680675
</pre>
681-
<p>
682-
As you can see, these search patterns give you a lot of power and control.
683-
</p>
684-
</paragraphs>
685-
686-
</subsection>
687-
688-
<conclusion>
689-
<title>Conclusion</title>
690676
<p>
691-
Hopefully, you now feel a bit more comfortable using the shell. The shell commands discussed above are summarized in Appendix <xref ref="ap_shell_cheat_sheet"/>.
677+
As you can see, these search patterns give you a lot of power and control.
692678
</p>
693-
</conclusion>
694679

695-
<exercise label = "basicShellCommands" numbered = "yes" language = "natural" adaptive="yes">
680+
681+
<exercise xml:id="quiz_basic_shell_commands">
682+
<title>Quiz: Basic Shell Commands</title>
696683
<statement>
697-
<p>
698-
You have a file named <term>data.txt</term> that contains the following lines:
699-
</p>
700-
<pre>apple
684+
<p>
685+
You have a file named <term>data.txt</term> that contains the following lines:
686+
</p>
687+
<pre>apple
701688
orange
702689
banana
703690
grape
704-
</pre>
705-
<p>
706-
Your task is to create a new file named <term>fruits.txt</term> and copy the contents of <term>data.txt</term> to <term>fruits.txt</term>. Next, append the word <c>kiwi</c> to <term>fruits.txt</term>. Then, display the contents of <term>fruits.txt</term> in the terminal. Next, count the number of fruits in <term>fruits.txt</term> and display the total count. Finally, overwrite the content of <term>data.txt</term> with the content of <term>fruits.txt</term> and rename <term>data.txt</term> to a new file named <c>fruits2</c>.
707-
</p>
708-
<p>
709-
Here are some commands you may need to perform the task. Rearrange the correct commands in the correct order by dragging and dropping.
710-
</p>
691+
</pre>
692+
<p>
693+
Your task is to create a new file named <term>fruits.txt</term> and copy the contents of <term>data.txt</term> to <term>fruits.txt</term>. Next, append the word <c>kiwi</c> to <term>fruits.txt</term>. Then, display the contents of <term>fruits.txt</term> in the terminal. Next, count the number of fruits in <term>fruits.txt</term> and display the total count. Finally, overwrite the content of <term>data.txt</term> with the content of <term>fruits.txt</term> and rename <term>data.txt</term> to a new file named <c>fruits2</c>.
694+
</p>
695+
<p>
696+
Here are some commands you may need to perform the task. Rearrange the correct commands in the correct order by dragging and dropping.
697+
</p>
711698
</statement>
712699
<blocks>
713-
<block order="1">
714-
<choice correct = "yes">
715-
<p>
716-
<c>cat data.txt &gt; fruits.txt</c>
717-
</p>
718-
</choice>
719-
<choice>
720-
<p>
721-
<c>cat data.txt &gt;&gt; fruits.txt</c>
722-
</p>
723-
</choice>
724-
</block>
725-
<block order="2">
726-
<p>
727-
<c>echo "kiwi" &gt;&gt; fruits.txt</c>
728-
</p>
729-
</block>
730-
<block order="3">
731-
<p>
732-
<c>cat fruits.txt</c>
733-
</p>
734-
</block>
735-
<block order ="4">
736-
<choice>
737-
<p>
738-
<c>wc -l &lt; fruits.txt</c>
739-
</p>
740-
</choice>
741-
<choice correct = "yes">
742-
<p>
743-
<c>wc -w &lt; fruits.txt</c>
744-
</p>
745-
</choice>
746-
</block>
747-
<block order="5">
700+
<block order="1">
701+
<choice correct="yes">
748702
<p>
749-
<c>cp -i fruits.txt data.txt </c>
703+
<c>cat data.txt &gt; fruits.txt</c>
750704
</p>
751-
</block>
752-
<block order="6">
705+
</choice>
706+
<choice>
753707
<p>
754-
<c>mv data.txt fruits2.txt</c>
708+
<c>cat data.txt &gt;&gt; fruits.txt</c>
755709
</p>
756-
</block>
757-
<block correct="no">
758-
<p>
759-
<c>rm data.txt fruits2.txt</c>
760-
</p>
761-
</block>
710+
</choice>
711+
</block>
762712
</blocks>
763713
</exercise>
764-
</section>
714+
715+
</subsection>
765716

717+
718+
719+
720+
<conclusion>
721+
<title>Conclusion</title>
722+
<p>
723+
Hopefully, you now feel a bit more comfortable using the shell. The shell commands discussed above are summarized in Appendix <xref ref="ap_shell_cheat_sheet"/>.
724+
</p>
725+
</conclusion>
726+
</section>

0 commit comments

Comments
 (0)