0% found this document useful (0 votes)
96 views2 pages

Eduard Hasanaj Lab 3

This document summarizes 5 exercises completed as part of an introduction to operating systems lab. The exercises include: 1) Filtering the output of ps -afe to show only root processes that started at a specific time. 2) Saving the list of logged in users to a file. 3) Creating a sed script to substitute the word "hi" with "hello" in a file. 4) Writing a script to transform all file names in the current directory to lowercase. 5) Writing a script to change the case of the letter 'd' to 'D' in all file names of a given directory.

Uploaded by

Eduard Hasanaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views2 pages

Eduard Hasanaj Lab 3

This document summarizes 5 exercises completed as part of an introduction to operating systems lab. The exercises include: 1) Filtering the output of ps -afe to show only root processes that started at a specific time. 2) Saving the list of logged in users to a file. 3) Creating a sed script to substitute the word "hi" with "hello" in a file. 4) Writing a script to transform all file names in the current directory to lowercase. 5) Writing a script to change the case of the letter 'd' to 'D' in all file names of a given directory.

Uploaded by

Eduard Hasanaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
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