Eduard Hasanaj Lab 3
Eduard Hasanaj Lab 3
Eduard Hasanaj Lab 3
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
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