#!/bin/bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Copyright (c) 2010 FSOCA final project | http://joaosantacruz.com # This script is licensed under GNU GPL version 2.0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Create a BASH script (1000-empty-files.sh) to create a new child directory # ./tmpfiles/ In that directory, using the script, create 1000 empty files using the format # firstname.lastname.xxxx (where firstname and lastname are your firstname and lastname). # The script should then create a empties.tar.gz archive in the directory that the script is # running containing a gzipped archive of the folder ./tmpfiles/ with all the files inside. # Extension: using the parameters -b or -g change whether a bzip2 or gzip file is created. # Modify script such that the first parameter defines how many files are created. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - clear echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo " 1000 Empty Files " echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "" tempdir="./tmpfiles/" if [ ! $1 ] then fnum=1000; else fnum=$1 fi if [ -d $tempdir ] # Check if directory exists then rm -Rf $tempdir fi if [ -f $filename ] # Check if file exists then rm -f $filename fi mkdir $tempdir cd $tempdir for (( i = 1 ; i <= $fnum; i++ )) do touch "joao.silva.$i" done cd .. case $2 in "-b") filename="empties.bz2" tar -jcf $filename $tempdir;; "-g") filename="empties.gzip" tar -zcf $filename $tempdir;; *) filename="empties.tar.gz" tar -zcf $filename $tempdir;; esac #tar -zcf $filename $tempdir if [ -f $filename ] # Check if directory exists then echo "File '$filename' containing $fnum empty files has been created!" echo -e "\n'ls -lh $filename' output:" ls -lh $filename fi echo -e "\nPress enter to continue and remove '$tempdir' directory." read pressedKey rm -Rf $tempdir echo "" echo "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" echo "Press [enter] key to continue. . ."; read pressedKey