Changes

Jump to: navigation, search
INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES
|- valign="top" style="padding-left:15px;"
|colspan="1" |Course NotesSlides:<ul><li>[https://ict.senecacollege.ca/~murray.saul/uli101/notes/Week02ULI101-Week3.pdf PDF] | [https://ict.senecacollege.ca/~murray.saul/uli101/notes/Week02ULI101-Week3.pptx PPTX]</li></ul>
Filename Expansion Symbols
* Asterisk '''*''' , Question '''?''' ,<br>Character Class '''[ ]''' and '''[! ]'''<br>
 
| style="padding-left:15px;"|Quotation Symbols
|}
 
= KEY CONCEPTS =
===Pathname Types===
But this method is '''inefficient''': it requires a LOT of typing and knowing which filenames to include as separate arguments.<br>You can use a special character to indicate to the Bash shell to match all files that end with the extension ".txt":
[[Image:globbing-demo-2.png|thumb|right|400px|'''Globbing''' is the process of expanding filenames as separate arguments that match an argument that uses a '''wildcard symbol''' <br>(such as '''*''').]]
<span style="font-family:courier;>'''ls *.txt'''<br>
<table cellpadding="5"><tr><th style="border-bottom: 1px solid black;text-align:left;">Filename Expansion SymbolQuoting Method</th><th style="border-bottom: 1px solid black;text-align:left;">Example</th></tr><tr><td>Place the character '''Place the character \ ''' <u>before </u> a special character'''</td><td><span style="font-family:courier">'''echo \*'''</span></td></tr><tr valign="top"><td>Contain special characters within '''Contain special characters with double-quotes'''<br>'''NOTE:''' Double quotes works for most special characters,<br>characters, but not all like special characters (such as $)<br></td><td><span style="font-family:courier">'''echo "* hello *"'''</span></td></tr><trvalign="top"><td>'''Contain Special character within single '''quotes'''<br>(Quotes out ALL special characters)</td><td><span style="font-family:courier">'''echo '* hello *''''</span></td></tr></table>  <br><br>
=INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES=
'''Perform the Following Steps:'''
# # Make certain that your current directory is '''your home directory'''.<br><br>
# Issue the following Linux command to run a checking script to ensure you created the CORRECT directory structure displayed as in the diagram:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week3-check-1</span><br><br>
# If you encounter errors and re-run the checking script until you receive a congratulations message.<br><br>
= INVESTIGATION 3: QUOTING SPECIAL CHARACTERS =
In this section, you will learn 3 methods to quote special characters so they behave only like text.
x:'''Perform the Following Steps:'''
# Make certain that you are currently located in your home directory.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo hello there</span><br><br>'''NOTE:''' the '''echo''' command is used to display text onto your terminal.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo * hello *</span><br><br>What happened? What is shown in addition to the text "hello". Why do you think those filenames are also being displayed?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo \* hello*</span><br><br>What do you notice? What does the \ character do?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo "* hello *"</span><br><br>Is there a difference between this command and the previous command?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo '* hello *'</span><br><br>Is there any difference between this command and the two previous commands?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">echo $USER</span><br><br>NOTE: USER is an environment variable that stores the current user's login name. The $ character immediately followed by the environment name causes it to expand to the value that the variable contains. Therefore the echo command displays the current login name of the user.<br><br># Issue the following Linux command (using single quotes): <span style="color:blue;font-weight:bold;font-family:courier;">echo '$USER'</span><br><br>What happened? Why is the output display like this?<br><br># Issue the following Linux command (using double quotes): <span style="color:blue;font-weight:bold;font-family:courier;">echo "$USER"</span><br><br>What happened? Why?<br><br># Let's use quoting special characters for a couple of other commands. Move to the '''lesson2''' directory. Confirm that you are currently located in the ''lesson2'' directory.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp /bin/ls .</span><br><br># Issue the '''ls'''Perform command to verify that there are copied files in your lesson2 directory.<br><br>NOTE: Although it is NOT RECOMMENDED to create a filename using a special character (remember that file naming rule?), we will create an empty file called "*"<br><br># Issue the Following Stepsfollowing Linux command (using single quotes): <span style="color:blue;font-weight:bold;font-family:courier;">touch '*'</span><br><br># Issue the '''ls''' command. Do you now see a file called "*" in addition to the other copied files?<br><br># Issue the following Linux command to remove the file called "*": <span style="color:blue;font-weight:bold;font-family:courier;">rm *</span><br><br># Issue the '''ls''' command to view the files in your current directory. What happened?!? Why is it dangerous to use special characters when creating filenames?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp /bin/ls .</span><br><br># Issue the following Linux command (using single quotes): <span style="color:blue;font-weight:bold;font-family:courier;">touch '*'</span><br><br># Issue the following Linux command (using single quotes): <span style="color:blue;font-weight:bold;font-family:courier;">rm '*'<br><br># Issue the '''ls''' command to confirm that the file called "*" has been in your current directory. What happened this time?<br><br># After you complete the Review Questions sections to get additional practice, then work on your online assignment 1 and complete the '''remaining''' sections 3 to 6 labelled: '''Directory Management''' , '''Practice Commands To Create A Directory Structure''' , '''Create A Directory Structure''' and '''Practice Specifying Path Names'''. When you have completed these remaining sections, and you main menu indicates you have completed 6 out of 6 sections, then you will have successfully completed your assignment #1.<br><br>
# X
<br><br>
= LINUX PRACTICE QUESTIONS =
[[Image:dir13week3-practice-question.png|left|300px|thumb|]]
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
# Write a single Linux command using relative pathnames to create the directory structure displayed in the diagram above.
# Write a single Linux command to create the empty files “.answers.txt” and “questions.txt” shown in the diagram above using absolute pathnames.
# Write a Linux command to display the following message:<br>*** Hello ***<br><br>
# Write a Linux command to display the following message (including quotation marks):<br>“This is my message”<br><br>
 
 
 
 
 
 
[[Category:ULI101]]
13,420
edits

Navigation menu