Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
82 views2 pages

Eduard Hasanaj Lab 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

LAB 3

Introduction to Operating Systems

 Worked by:
o Eduard Hasanaj
 Lecturer
o Orges Cico

DECEMBER 2017
Exercise 1
In this exercise we are required to filter the output of command ps –afe all root’s processes that
have started at 11:45 (in my case I used 00:01:12). Commands used to perform this task:
ps -afe | tr -s ' ' | grep root | grep "00:01:12" | cut -f1,2,3,5,8 -d ' '

Exercise 2
We need to find the list of users logged in linux and save only the name to a file called login.log.
To do the task following command is executed:
who | tr -s ' ' | cut -f1 -d ' ' > login.log

Exercise 3
We need to write a script for sed which takes an input file and substitute word “hi” with “hello”.
First I created a file called input.txt with content:
This a file example
in which every occurrence of the word hi
(hi,hi , etc..)
should be substituted with the word hello
Then inside a script called “sedscript” I wrote:
s/\bhi\b/hello/g p

To perform task required I executed in terminal following command:


sed -f sedscript input.txt
Exercise 4
We are required to write a script which transforms all names of files in current directory to lower
case. I use back ticks to perform commands in script like ls, ts
#!bin/bash/
for i in `ls`
do
mv $i `echo $i | tr [A-Z] [a-z]`
done

Exercise 5
#!bin/bash/
for i in `ls $1`
do
name=`echo $i | sed -n s/d/D/gp`
mv "$1/$i" "$1/$name"
done

You might also like