When the shell is reading the command line what is the


Question 1.

Study the following filenames which contain wildcards.

[A-Za-z]*.txt

text.*
file?.txt
[!0-9]*.tex

• Give three examples of filenames that would match each of the following wildcard patterns.
• Give three examples of filenames that would not match each of the above wildcard patterns.

Question 2. 
Assume that a file's permissions give you read and write access.
• What operations can you perform on the file if it is in a directory which has "r" (read) only access?
• What operations can you perform on the file if it is in a directory which has "x" (execute) only access?

Question 3. 
When the shell is reading the command line what is the di?erence between text enclosed between double quotes (") and text enclosed between single quotes (')? Consider two cases.

• there are environmental variables and
• there is no environmental variable.

Question 4.

Provide English description for the regular expressions listed below.

ab.cd
ab*cd
ab.*cd
abb*cd
^abc
^abc$
[abc]d
[^abc]d
[A-Z]xy
[A-Z_][a-zA-Z0-9]*

(For instance, the regular expression "x*$" could be described as "zero or more x at the end of a line".)

Question 5.

• Give the command-line of using find to list all the files having specific username in the current directory
• Give the command-line of using find to list all the subdirectories in the current directory
• Use find to produce a long ls listing of all files in /usr/bin that are more than 750Kb long. Give all the arguments and options in the following command-line
find ..... -exec ls -l {} \;

Note that pay special attention to the arguments or options. The semicolon must be escaped, but not the {}.

Question 6.

Create a big file (If you don't know how to create a big file, try ls -l /usr/bin > bigfile). Create two copies of it using cp, and call them
big1 and big2.

• Give the command-line of compressing big1 using gzip (should produce big1.gz).
• Compress big2 using bzip2(should produce big2.bz2).
• Give the command-line of comparing the sizes of the compressed files (big1.gz and big2.bz2) and the original (bigfile) using ls -l
• Give the command-line of checking the file type of compressed files and the original.
• Give the command-line of displaying the contents of big1.gz using zcat and big2.bz2 but using bzcat without uncompress them. (You
may pipe the output to head -10 to avoid lots of output).

Question 7.
• Use tar to create an archive (don't use the z or j option) of all the files in the current directory.
• Compress the tar file with gzip.
• View the contents of archive with gunzip -c gzipped-tar-file | tar tfv -
• View without using gunzip but use the tar instead. (Hint: ?nd the right option to use from the man page).
• Create a subdirectory of the current directory.
• Use tar to unpack the archive into that directory at the current directory.

Question 8.
Assume you have a text file called file. Explain the following command lines.

1. sed "s/the/a/g" file
2. sed -n "s/[A-Z]/&/gp" file
3. sed "32,45 s/[()]//g" file
4. sed "/^$/d" file
5. sed "s/\([0-9]\)-\([0-9]\)/\1\2/g" file
6. sed "80q" file
For example, sed 's/fox/ox/g' file will replace all occurance of fox with ox and not the just the first one in file.

Solution Preview :

Prepared by a verified Expert
Software Engineering: When the shell is reading the command line what is the
Reference No:- TGS0664934

Now Priced at $70 (50% Discount)

Recommended (92%)

Rated (4.4/5)