Using a Linux terminal, write a script, called UnixHistory.sh, which will generate an abbreviated
"tree" of the Unix and Unix like operating system ancestry. The data source, as
always, can be found on Wikipedia:
https://en.wikipedia.org/wiki/File:Unix_history.svg
The Unix history begins with a directory named ResearchUnix that has two
children: BSD and Commercial.
BSD has two children FreeBSD and NextStep, NextStep has a single child
directory: MacOSX.
Commercial has one sub-directory named Solaris
NOTE all the elements mentioned above are directories, created with the mkdir
command. We haven't discussed any files (yet).
Inside of each directory, there should be a regular file called Year (create
this with an echo > command, just as we have in lecture). The Year file holds
the approximate beginning date for each Unix variant. Here is a list of values
for the corresponding Unix variant:
ResearchUnix = 1972
Commercial = 1984
BSD = 1977
Solaris = 1991
FreeBSD = 1993
NextStep = 1988
MacOSX = 2002
A sample run of your script must look like this:
$ bash UnixHistory.sh
$
Which is to say nothing should be printed if all went well.
You can check your work with the find command:
$ find
.
./UnixHistory.sh
./ResearchUnix
./ResearchUnix/BSD
./ResearchUnix/BSD/NextStep
./ResearchUnix/BSD/NextStep/Year
./ResearchUnix/BSD/NextStep/MacOSX
./ResearchUnix/BSD/NextStep/MacOSX/Year
./ResearchUnix/BSD/Year
./ResearchUnix/BSD/FreeBSD
./ResearchUnix/BSD/FreeBSD/Year
./ResearchUnix/Commercial
./ResearchUnix/Commercial/Solaris
./ResearchUnix/Commercial/Solaris/Year
./ResearchUnix/Commercial/Year
./ResearchUnix/Year
$ cat ResearchUnix/BSD/NextStep/Year
1988
$ cat ResearchUnix/Commercial/Solaris/Year
1991
$
You will probably want to check all the Year files to be sure of a high grade...
The order of output from find does not have to exactly match the example above.
But the directory structure under ResearchUnix must be precisely as described.
#!/bin/bash
#this is to create directory structure with parent directory ResearchUnix
mkdir -p ResearchUnix/{BSD/{FreeBSD,NextStep/MacOSX},Commercial/Solaris}
#find command to find directory and sub directtory in current directory
dir=`find . -type d`
for i in $dir
do
if [[ $i != '.' ]]; then
#statements
#in each directory path create file year
touch $i/year
fi
done
echo 1972 > ResearchUnix/year
echo 1984 > ResearchUnix/Commercial/year
echo 1977 > ResearchUnix/BSD/year
echo 1991 > ResearchUnix/Commercial/Solaris/year
echo 1993 > ResearchUnix/BSD/FreeBSD/year
echo 1988 > ResearchUnix/BSD/NextStep/year
echo 2002 > ResearchUnix/BSD/NextStep/MacOSX/year
this will do precisely as stated.give file permission before execute using chmod command.
If have any query in understanding this please ask
Get Answers For Free
Most questions answered within 1 hours.