1.0 INTRODUCTION
To be a strong Linux administrator, you need strong bash scripting skills. Scripts make a Linux administrators life easy. The writing of the scripts can be a challenge, but once they are written, if done well, they will serve the administrator a lifetime. This assignment requires us to take a data file, parse it, run some stats on it, and change it. Hopefully some of the things we did will be of some use to you.
2.0 PROJECT
I. Requirements
• Linux VM Machine
• Root access
II. Data File
Here is the original data file.
The Unix operating system was conceived and implemented in the 1960s and first released in 1970. Its wide availability and portability meant that it was widely adopted, copied and modified by academic institutions and businesses, with its design being influential on authors of other systems. One so-called Unix-like system was GNU, started in 1984, which had the goal of creating a POSIX-compatible operating system from entirely free software. In 1985, Richard Stallman created the Free Software Foundation and developed the GNU General Public License (GNU GPL), in order to spread the software freely. Many of the programs required in an OS (such as libraries, compilers, text editors, a Unix shell, and a GUI) were developed by the early 1990s, so that most of the requirements for an operating system were complete, although low level elements such as device drivers, daemons, and the kernel were stalled and incomplete. Linus Torvalds has said that if the GNU kernel had been available at the time, he would not have decided to write his own.
III. Objectives
Here are the objectives of this assignment
Working with Generic Commands:
Use the following file for this Task:
Project #4: DATA
Create a script that meets the following criterion:
i. SCRIPT asks user for FILENAME
ii. SCRIPT outputs the filename contents but with the following
Modifications:
1. Displays Word Count at top of output
2. Displays Line Count at top of output
3. Display Inode Block File is Using at top of output (HINT: stat)
4. Display size of file at top of output
5. Replace all “a”’ with “A”, Replace
6. Replace “The” on Lines 1 & 5 with “HANK”
IV. Script
#!/bin/bash
echo Enter the filename:
read file
wc -w $file > wordcount
wc -l $file > linecount
ls -i $file > inoded
ls -s $file > size
sed s/a/A/g $file > aA
sed -e 's/The/HANK/' -e '1s/the/HANK/g' -e '5s/the/HANK/g' $file > HANK
V. Output
1. wordcount
171 data.txt
2. linecount
10 data.txt
3. inoded
6029320 data.txt
4. size
4 data.txt
5. aA
The Unix operAting system wAs conceived And implemented in the 1960s And first releAsed in 1970. Its wide
AvAilAbility And portAbility meAnt thAt it wAs widely Adopted, copied And modified by AcAdemic institutions And
businesses, with its design being influentiAl on Authors of other systems. One so-cAlled Unix-like system wAs
GNU, stArted in 1984, which hAd the goAl of creAting A POSIX-compAtible operAting system from entirely free
softwAre. In 1985, RichArd StAllmAn creAted the Free SoftwAre FoundAtion And developed the GNU GenerAl
Public License (GNU GPL), in order to spreAd the softwAre freely. MAny of the progrAms required in An OS
(such As librAries, compilers, text editors, A Unix shell, And A GUI) were developed by the eArly 1990s, so thAt
most of the requirements for An operAting system were complete, Although low level elements such As device
drivers, dAemons, And the kernel were stAlled And incomplete. Linus TorvAlds hAs sAid thAt if the GNU kernel
hAd been AvAilAble At the time, he would not hAve decided to write his own.
6. HANK
HANK Unix operating system was conceived and implemented in HANK 1960s and first released in 1970. Its wide
availability and portability meant that it was widely adopted, copied and modified by academic institutions and
businesses, with its design being influential on authors of other systems. One so-called Unix-like system was
GNU, started in 1984, which had the goal of creating a POSIX-compatible operating system from entirely free
software. In 1985, Richard Stallman created HANK Free Software Foundation and developed HANK GNU General
Public License (GNU GPL), in order to spread the software freely. Many of the programs required in an OS
(such as libraries, compilers, text editors, a Unix shell, and a GUI) were developed by the early 1990s, so that
most of the requirements for an operating system were complete, although low level elements such as device
drivers, daemons, and the kernel were stalled and incomplete. Linus Torvalds has said that if the GNU kernel
had been available at the time, he would not have decided to write his own.
3.0 SUMMARY
You can imagine how long it would take to do those silly changes if you had to do it by hand. Now what if you had to do it 100 times, or it was a user list and you were changing a grade level because of graduation. It would in theory save you hours. Scripting truly is an administrator’s best friend.