Introduction to shells
Overview
Why do we need a shell?
Shell
syntax
Types of shell
command
Simple
commands
Pipelines
Grouping
commands
Exit status
List commands
Arithmetic
Operators and
functions
Making
decisions
The 'test'
statement
Operators used by 'test'
The 'if'
statement
Loops
'For' loops
'While' and
'until' loops
Searching for files
Arguments to
'find'
Formatted output
Arguments to
'printf'
Passing information to
scripts
Scripts with
arguments
Parameter
expansion
Summary
Exercises
|
Exercises
-
List all regular files in your home directory whose size is less
than 512 bytes.
View solution
-
What is the maximum length of a line in
/usr/dict/words ?
-
Write a script called mcat which will be identical
to cat with the following difference: if any file
argument given to mcat either does not exist or is
unreadable, mcat will not send any output to
the standard output. The behaviour of cat is such that
all its readable arguments are copied to standard output.
View solution
-
List the name of each regular file in the current directory (or
any subdirectory of it), together with the first line of the
file.
-
List all users currently logged in to the system, in 4 columns
of width 10 characters, so:
chris jo sam george
pete sue dave jane
emma bill
View solution
-
Write a script to prompt the user for two numbers, representing
the width and height of a rectangle in cm, and display the
area of the rectangle both in square metres and in square
inches (1 inch = 2.54 cm).
-
Write a script to take text input from standard input, and copy
it to standard output with each line preceded by a line number in
the same manner as cat -n . Do not use the command
cat .
View solution
|