Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #check if the script is called with 2 arguments
- if [ $# -ne 2 ]
- then
- echo "USAGE: `hostname $0` ./source_folder ./destination_folder"
- exit 1
- fi
- #stick tha argument valuez
- FROM=$1
- TO=$2
- #check if a destination folder exists and if not create it
- #-p apparently means creating all the possible subfolders so its better if used
- if [ ! -d $TO ]
- then
- mkdir -p $TO
- fi
- #get the files that start with a number, have an x amount of lower case letterz and have an .out extension
- files=`ls -l $FROM | awk '$1~/^-/ && $9~/^[0-9][a-z][a-z]*\.out$ {print $9}'`
- for file in $files
- do
- #copy-paste every file from 1 place 2 anotha
- cp ${FROM}${file} ${TO}${file}
- done
- #so in the next line we just calculate the summed suze of the pasted filez that we have execute permission on
- total_size=`ls -l $TO | awk '$10~/^[0-9][a-z][a-z]*\.out$ {print $0}' | grep ^-..x | awk 'BEGIN {total=0;} {total+=$5} END {print total;}'`
- #print on screen, 20 points in tha bag and cya lata aligata
- echo "Vkupnata golemina na kopiranite datoteki koi korisnikot moze da gi izvrsuva e $file_size"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement