Perl Assignment #7:
Regular Expressions
CS 447/647
Spring, 2012
Due:
3/13/12
Read
chapter 7 of Learning Perl. Do exercises 4 and 5.
Read
chapter 8 of Learning Perl. Do exercises 1 and 3.
script assign7.txt
PS1=’$
‘
cat ex7-4.pl
perl ex7-4.pl
…
exit
Submit assign7.txt via Web Campus
Hands-On
Exercise
Add a root cron
job to update your system at 2:01 AM each day:
sudo bash
crontab
–e # do not include this in your typescript
# m
h dom mon dow command
01 02 *
* * apt-get -qq
--force-yes upgrade
crontab –l # You’ll run this again in your
script session below
Backup your
root filesystem
echo “You found me” > /root/iamlost
apt-get install dump
rm
–f /tmp/dump
time dump
0f /tmp/dump /
# /home/dump if /home is a separate partition
#
This may take a while depending on how fast your disk
is
#
You can use the –e or –E flags with a list of inodes to exclude large files .iso
.vmdk .exe
#
To see the inodes of your large files: find /home
-type f -size +90000k -exec ls -i
{} \;
#
To create a list of inodes
of your large files to exclude:
# find /home -type f
-size +90000k -print0 | xargs -0 stat -c %i > /tmp/exclude
#
To dump using the exclude list
# time dump 0fE /tmp/dump /tmp/exclude /
#
See the man pages for details
(Hands-On
continued on other side)
Restore /root/iamlost to /tmp/restore
mkdir
/tmp/restore
cd
/tmp/restore
restore if /tmp/dump # /home/dump if /home is a separate partition
cd
/root
ls
add iamlost
ls # iamlost
should now be tagged
ex #
extract
1 # use volume 1
n # do
not set owner/mode
quit
ls
script /tmp/handson7.txt
PS1=’$ ‘
alias ls=ls
cat root/iamlost
crontab -l
Copy a
directory using tar.
cd $HOME
mkdir
olddir
mkdir
newdir
cd
olddir
touch abc
touch def
mkdir subdir
# The
spacing in the following line is critical
tar cvf - . | (cd ../newdir; tar xf -) # don’t forget the pipe symbol
cd ..
alias ls=ls
ls
–l olddir
ls
–l newdir
exit # end script session
Submit
handson7.txt to Web Campus