Changes

Jump to: navigation, search
INVESTIGATION 2: FILENAME EXPANSION
<div style="font-family:courier;margin-left:50px;font-weight:bold;">abc.txt<br>def.text<br>hij.TxT<br>1a4.txt<br>123.TXT<br>456.txt<br>6u9.txt<br>
ab2.html<br>1234.txt<br>abcdef.txt<br>abcde.txt<br><br></div>
<ol><li value="4">Before proceeding, let's run a checking script to make certain that you created these regular files correctly:<br>Make certain that your current directory is '''your home directory'''.<br><br></li><li>Issue the following Linux command to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week3-check-3</span><br><br></li><li>If you encounter errors and re-run the checking script until you receive a congratulations message, and continue in this section.<br><br>'''NOTE: To become comfortable with using filename expansion symbols, an excellent practice method is to create multiple files (you have already done that), look at the Linux command using filename expansion symbols and view the listing of files in the current directory that match and then write down on a paper the expected output of commands that use filename expansion symbols. You can then run the command to see the results in order to check your work.'''<br><br>Let's try this for each of the situation below:<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls ???.txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls ?????.txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls ??????.txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls [0-9].txt</span><br>Write down the expected output on paper, then issue the command to check your answer. Did the command work? What does this teach you about the character class [ ] symbol?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls [0-9][0-9][0-9].txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls [a-z][a-z][a-z].txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command (using character class with UPPERCASE letters): <span style="color:blue;font-weight:bold;font-family:courier;">ls [A-Z][A-Z][A-Z].txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command (using character class using alpha-numeric characters): <span style="color:blue;font-weight:bold;font-family:courier;">ls [a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9].txt</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls *.txt</span><br>Write down the expected output on paper, then issue the command to check your answer. Did ALL text files get listed? Why not?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls *.[tT][xX][tT]</span><br>Write down the expected output on paper, then issue the command to check your answer.Did ALL text files get listed this time? If so, why?<br><br></li><li>'''NOTE:''' We have just been using filename expansion symbols just with the ls command.<br>Filename expansion symbols can be used for ANY Linux file management command (e.g. '''cat''', '''more''', '''less''', '''cp''', '''mv''', '''rm''', '''ls''', etc.).<br><br>Let's get some practice issuing these other Linux file management commands.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">file *.[tT][xX][tT]</span><br>Write down the expected output on paper, then issue the command to check your answer.<br><br><li>Change to the '''commands''' directory using an '''absolute''' pathname.<br><br></li><li>Issue a Linux command to confirm that you are now in the '''commands''' directory.<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp /bin/l.* .</span><br>View the contents of the contents directory. What did this command do?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">rm *</span><br><br>View the contents of the contents directory. What did this command do?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp /bin/l? .</span><br>View the contents of the contents directory. What did this command do?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">rm l[!s]</span><br>View the contents of the contents directory. What did this command do?<br><br></li><li>Use a text editor (nano or vi) to create the file called '''ab''' in the '''commands''' directory that contains the line of text below,<br>and then save editing changes to this file:<br><span style="font-family:courier;">This is file ab</span><br><br></li><li>Use a text editor (nano or vi) to create the file called '''cd''' in the '''commands''' directory that contains the line of text below,<br>and then save editing changes to this file:<br><span style="font-family:courier;">This is file cd</span><br><br></li><li>Use a text editor (nano or vi) to create the file called '''ef''' in the '''commands''' directory that contains the line of text below,<br>and then save editing changes to this file:<br><span style="font-family:courier;">This is file ef</span><br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cat ??</span><br><br>View the contents of the contents directory. What did this command do? Why does the output look strange?<br><br></li><li>Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cat [!l][!s]</span><br><br>View the contents of the contents directory. What did this command do? Does the output look better? If so, why?<br><br></li><li>Before proceeding, let's run a checking script to make certain that you created these regular files correctly:<br>Make certain that your current directory is '''your home directory'''.<br><br></li><li>Issue the following Linux command to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week3-check-4</span><br><br></li><li>If you encounter errors and re-run the checking script until you receive a congratulations message, and continue in this sectionthe next INVESTIGATION.<br><br></ol>
= INVESTIGATION 3: QUOTING SPECIAL CHARACTERS =
13,420
edits

Navigation menu