You are on page 1of 2

File: /home/sysadmin/Documents/myscripts/script

#!/bin/bash
#Requirement I
echo "creating the file Shakespeare using: touch Shakespeare"
touch Shakespeare
echo "We are going to use the redirection operator > to put contents to Shakespeare"
echo "Shall I compare thee to summer's day?
though art more lovely and more temperate" > Shakespeare
mv Shakespeare sonnet-18.txt
mkdir ~/poetry
mv sonnet-18.txt ~/poetry
echo "Please check if Shakespeare was renamed to sonnet-18.txt and the new file
exists in $USER/poetry"
-----------------------------------------------------------------------------------#!/bin/bash
#Requirement II
echo "creating the file Shakespeare using: touch Shakespeare"
touch Shakespeare
echo "We are going to use the redirection operator > to put contents to Shakespeare"
echo "Shall I compare thee to summer's day?
though art more lovely and more temperate" > Shakespeare
mv Shakespeare sonnet-18.txt
mkdir ~/poetry
mv sonnet-18.txt ~/poetry
echo "Please check if Shakespeare was renamed to sonnet-18.txt and the new file
exists in $USER/poetry"
------------------------------------------------------------------------------------#!/bin/bash
#Requirement III
cd /
ls /usr/share
cd /usr/share
pwd
echo "=========================== THE CONTENTS OF /usr/share/doc =================="
ls doc
echo "============================= END OF THE LIST ==============================="
echo "============================ THE CONTENTS OF /usr/ ====================="
ls ..
echo "============================= END OF THE LIST ==============================="
echo "============================= THE CONTENTS OF / ============================="
ls ../..
echo "============================= END OF THE LIST ==============================="
echo ~
cd ~
touch ~/sampleFile.txt
echo "This is a sample file" > sampleFile.txt
echo "============================= SAMPLE FILE ==========================="
cat ~/sampleFile.txt
----------------------------------------------------------------------------------#!/bin/bash
#Requriement IV
hostname
echo "-> The name of my machine"
echo "===== Finding all files with a substring hostname ======"
locate hostname
echo "====== END OF LIST ====="
-----------------------------------------------------------------------------------#!/bin/bash
#Requirement V
echo "================= LISTING THE CONTENTS OF A DIRECTORY USING * ============"
echo *
echo "****************** END OF THE LIST *********************************"
touch ~/poetry/sonnet-19.txt
echo "When in disgrace with Fortune and men's eyes,
I alone be weep my outcast state." > ~/poetry/sonnect-19.txt

Page 1 of 2

File: /home/sysadmin/Documents/myscripts/script
cat ~/poetry/*.txt
rm -R ~/poetry/
----------------------------------------------------------------------------------#!/bin/bash
#Requirement V
echo "===================== Retrieving all directories under your directory ================="
find ~ -type d
echo "======================================== END =========================================="
echo "===================== Retrieving all files under your directory ================="
find ~ -type f
echo "======================================== END =========================================="

Page 2 of 2

You might also like