DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with the SCO OpenServer system shell

Command language exercises


1-1.
What happens if you use an * (asterisk) at the beginning of a filename? Try to list some of the files in a directory using the * with the last letter of one of your filenames. What happens?

1-2.
Try to enter the following two commands:
   cat [ 0-9 ] *

echo *

1-3.
Is it acceptable to use a ``?'' at the beginning or in the middle of a pattern? Try it.

1-4.
Do you have any files that begin with a number? Can you list them without listing the other files in your directory? Can you list only those files that begin with a lowercase letter between a and m? (Hint: Use a range of numbers or letters in [ ]).

1-5.
Is it acceptable to place a command in background mode on a line that is executing several other commands sequentially? Try it. What happens? (Hint: Use ``;'' and ``&.'') Can the command in background mode be placed in any position on the command line? Try placing it in various positions. Experiment with each new character that you learn to see the full power of the character.

1-6.
Redirect the output of pwd and ls into a file by using the following command line:
   cd; pwd; trial; ls >> trial
Remember, if you want to redirect both commands to the same file, you have to use the ``>>'' (append) sign for the second redirection. If you do not, you will wipe out the information from the pwd command.

1-7.
Instead of cutting the time out of the date response, try redirecting only the date, without the time, into banner. What is the only part you need to change in the following command line?
   banner `date | cut -c12-19`

Answers


1-1.
The * at the beginning of a filename refers to all files that end in that filename, including that filename.

$ ls *t
cat
123t
new.t
t
$


1-2.
The command cat [0-9]* produces the following output:
   1memo
   100data
   9
   05name
The command echo * produces a list of all the files in the current directory.

1-3.
You can place ``?'' in any position in a filename.

1-4.
The command ls [0-9]* lists only those files that start with a number.

The command ls [a-m]* lists only those files that start with the letters ``a'' through ``m.''


1-5.
If you placed the sequential command line in the background mode, the immediate system response was the PID number for the job.

No, the & (ampersand) must be placed at the end of the command line.


1-6.
The command line would be:
   cd; pwd > junk; ls >> junk

1-7.
Change the -c option of the command line to read:
   banner `date | cut -c1-10`

Next topic: Shell programming
Previous topic: Using the nohup command

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005