Return to Operationg Systems home
Realize a bash script that receives three parameters from the command line:
The script must:
Write two versions of the script:
for-in
for-in
Realize a bash script that:
Suppose that rows of the file do not contain spaces.
Realize a bash script that:
A textual file (ASCII) has a not definite format, i.e., it includes an indefinite number of rows, each of which contains an indefinite number of strings.
Realize a bash script that prints on standard output the absolute frequency of all the strings contained in the files.
Example:
With the following input file:
the imagination of nature is far far greater than the imagination of man
(by Richard P. Feynman)
the script must print (in a not defined order):
the 2 imagination 2 of 2 nature 1 is 1 far 2 greater 1 than 1 man 1
Suppose that the name of the input file is passed from the command line, but in the case it is not present, the name of the file must be read from standard input.
Suggestions:
for-in + cat
A bash script receives two parameters from the command line:
The bash script must check, at each time interval, if the process is present in the system.
If the process remains in the Z
state (i.e., zombie) for more than 5 consecutive checks, the script must terminate.
Suggestion:
The command ps -el
provide an output similar to the following:
UID PID PPID F CPU PRI NI RSS S ADDR TTY TIME CMD 0 1 0 4000 0 31 0 568 Ss 6fd9cd4 ?? 0:00.20 /sbin/launchd 0 10 1 4000 0 31 0 1292 R+ 6fd9384 ?? 0:00.59 /usr/libexec/kextd 0 11 1 4000 0 31 0 3412 Z 6fd982c ?? 0:02.10 /bin/ls
This output, properly parsed, can provide the needed informations to solve the problem.
Note that the character Z
in the column labeled with S
indicates the process is a zombie.